在eclipse中首次MySQL连接数据库除了把驱动复制到lib下,还需要配置其他的吗?

2025-03-26 02:43:23
推荐回答(2个)
回答1:

驱动复制过后,不需要在配置其它了,只需要写连接即可:
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://"+host+"/"+dbname,username,password);
Statement Stmt=conn.createStatement();
ResultSet rs=Stmt.executeQuery(sql);
这是基本的数据库操作方法
大概流程就是加载驱动类,创建连接,执行数据库操作,关闭

回答2:

就是构建路径而已,没有必要非要在lib下,盘里面一样可以的
build
path