Guest User

Untitled

a guest
Aug 17th, 2016
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. package com.cry.JDBC;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5.  
  6. public class ConnectDB {
  7.  
  8. public static Connection getConnection(){
  9.  
  10. Connection myConn = null;
  11. String myUrl = "jdbc:mysql://localhost:3306/todoproject?characterEncoding=UTF-8&useSSL=false";
  12. String username = "root";
  13. String password = "123456";
  14. try{
  15. Class.forName("com.mysql.jdbc.Driver");
  16. myConn = DriverManager.getConnection(myUrl, username, password);
  17.  
  18. return myConn;
  19.  
  20. }catch(Exception event){
  21. event.printStackTrace();
  22.  
  23. return null;
  24. }
  25. }
  26.  
  27. }
Add Comment
Please, Sign In to add comment