package com.shiliuxingbang.utils;
import java.sql.Connection;
import java.sql.DriverManager;
import com.mysql.jdbc.PreparedStatement;
import com.sun.corba.se.spi.orbutil.fsm.Guard.Result;
public class DBUtils {
/*
* 建立数据库连接
*/
public static Connection getConnection(){
try {
String url="jdbc:mysql://localhost:3306/shiliuxingbang";
String user="root";
String password="123456";
//加载驱动
Class.forName("com.mysql.jdbc.Driver");
//获取数据库连接
Connection con=DriverManager.getConnection(url, user, password);
return con;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
JDBC连接数据库
最新推荐文章于 2022-06-13 16:37:56 发布