标签:java mysql
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class DBConnection { private static final String name = "root"; private static final String pass = ""; public static Connection ConnectDB() { Connection con = null; try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/mytestdb", name, pass); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return con; } }
标签:java mysql
原文地址:http://jishunote.blog.51cto.com/4643968/1690386