我的代码是 -
package textmessenger;
import java.sql.*;
public class Main {
public static void main(String[] args) {
// TODO code application logic here
try {
String con = "jdbc:mysql://SQL09.FREEMYSQL.NET:3306/a5189576";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
int updateQuery = 0;
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(con, "user", "pwd");
statement = connection.createStatement();
String QueryString = "select * from names";
rs = statement.executeQuery(QueryString);
System.out.println("Executed");
}
catch(Exception ex){
ex.printStackTrace();
}
}
}
当我运行此程序时,输出中出现“Error”。我哪里错了? 我在NetBeans中尝试过SQL编辑器,它在那里工作得非常好。 在此先感谢:)
答案 0 :(得分:0)
从您现在发布的堆栈跟踪中,您需要下载MySQL JDBC驱动程序并将其包含在您的项目中: