mysql无法在Java中创建SQL语句
很好,为游戏编写登录检查器,并从C#切换到java。问题是我正在使用旧代码作为exmaple,但在从connection创建语句时一直遇到这个问题。我得到“找不到createStatement()符号”。是否有一种新的方法来执行SQL语句,或者是否有其他错误
这是源代码
import java.sql.*;
public class SQLCheck {
public Connection con;
public void connect(){
String host = "somewhereoutthere";
String username = "stuff";
String pass = "haclmolg";
String db = "users";
try{
Class.forName("com.mysql.jdbc.Driver");
String connectionUrl = "jdbc:mysql://"+host+"/"+db+"?";
con = (Connection) DriverManager.getConnection(connectionUrl,username,pass);
System.out.println("Server: Connected to MYSQL");
} catch(SQLException e){
System.out.println("Server: SQL EXECEPTION: " + e.toString());
} catch (ClassNotFoundException cE){
System.out.println("Server: Class not found: " + cE.toString());
}
}
boolean checkLogin(String userName, String password){
boolean correct = false;
Statement s = con.createStatement();
}
}
共 (0) 个答案