import java.sql.*;
public class connectMySQL
{
public static void mian(String args[])
{
String driver="org.mm.mysql.Driver";
String url="jdbc:mysql://localhost:3360/mysql?";
String user="root";
String password="";
try
{
Class.forName(driver);
}
catch(Exception e)
{
System.out.println("无法加载驱动程序:"+driver);
}
try
{
Connection con=DriverManager.getConnection(url,user,password);
if(!con.isClosed())
System.out.println("数据库连接成功!");
con.close();
}
catch(SQLException ee)
{
//System.out.println("数据库连接失败!");
System.out.println(ee.getMessage());
}
}
}
这些代码有什么错误啊?
public class connectMySQL
{
public static void mian(String args[])
{
String driver="org.mm.mysql.Driver";
String url="jdbc:mysql://localhost:3360/mysql?";
String user="root";
String password="";
try
{
Class.forName(driver);
}
catch(Exception e)
{
System.out.println("无法加载驱动程序:"+driver);
}
try
{
Connection con=DriverManager.getConnection(url,user,password);
if(!con.isClosed())
System.out.println("数据库连接成功!");
con.close();
}
catch(SQLException ee)
{
//System.out.println("数据库连接失败!");
System.out.println(ee.getMessage());
}
}
}
这些代码有什么错误啊?
illgates' is not allowed to connect to this MySQL server"
Press any key to continue...
conn = DriverManager.getConnection("jdbc:mysql://localhost/EP?user=root&password=qqdiy0&useUnicode=true&characterEncoding=gbk"); EP是库名
另外,是main不是mian!String driver="com.mysql.jdbc.Driver";在我的机子上通过,我的没mysql-jdbc是3.11。
String url ="jdbc:mysql://localhost/softforum?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1"
//testDB为你的数据库名
Connection conn= DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
你的数据库名是“mysql?”???如果数据库名是“mysql”那是不用“?”的。