连接数据库

public class jdbctest {
public static void main(String[] args) throws Exception{
String url="jdbc:mysql://localhost:3306/da?useUnicode=true&characterEncoding=utf8";
String user="root";
String password="";
Connection conn=null;
Statement st=null;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection connection = DriverManager.getConnection(url,user,password);


} catch (Exception e) {
e.printStackTrace();
}finally{
conn.close();
}
}
}
posted @ 2023-12-13 17:22  涨涨涨张  阅读(3)  评论(0编辑  收藏  举报