下在一个JDBC,放在CLASSPATH里。 import java.sql.*; Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn; conn = DriverManager.getConnection("jdbc:mysql://localhost/test"); Statement smt = conn.createStatement(); { ResultSet rs = smt.executeQuery("select * from struct order by id"); while(rs.next()) {
} rs.close(); } smt.close(); conn.close();
请问MYSQL还要什么设置吗?为什么会出现:java.sql.SQLException: Server configuration denies access to data source?还有,用不用加登录名和密码啊?
现在的问题是:Class.forName("com.mysql.jdbc.Driver").newInstance();可以执行,但是连接不上!总是出现Server configuration denies access to data source,请问这是怎么回事?我用的是:Connection con=DriverManager.getConnection("jdbc:mysql://localhost/lianxi?user=root&password=198181zb");lianxi是我的数据库名,198181zb是密码! 在线等待
import java.sql.*;
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn;
conn = DriverManager.getConnection("jdbc:mysql://localhost/test");
Statement smt = conn.createStatement();
{
ResultSet rs = smt.executeQuery("select * from struct order by id");
while(rs.next())
{
}
rs.close();
}
smt.close();
conn.close();
在线等待
在 lianxi 数据库下添加 root 用户!