文章标题

来源:互联网 发布:网络摄像头修改ip 编辑:程序博客网 时间:2024/06/06 03:21

JDBC连接Mysql数据库API:

String database = "test";String driver = "com.mysql.jdbc";String uri = "jdbc:mysql://localhost:3306/" + database;String user = "root";String password = "1234";String sql = "";  //sql语句try{    Class.forName(driver);    Connection conn = DriverManager.getConnection(url,user,password);    PreparedStatement pst = conn.prepareStatement(sql);}catch(ClassNotFoundException e){    e.printStackTrace();}catch(SQLException e){    e.printStackTrace();}
0 0
原创粉丝点击