我有一个在 MySQL 数据库上执行 CRUD 的 Java 程序。
为此,我一直在使用:
Eclipse Indigo
Java 1.6
MySql-Connector-java-5.1.19-bin.jar
我尝试在一台新机器
上执行相同的代码:
Eclipse Juno
Java 1.7
MySql-Connector-java-5.1.19-bin.jar.
我已将 MySql 连接器添加到 Eclipse Juno 中项目的构建路径。
但是,ant 构建失败,并出现有关缺少应从连接器获取的类和包的错误:
Buildfile: /home/rudra/Softwares/openfire/openfire_src/build/build.xml
init:
compile:
[javac] Compiling 14 source files to /home/rudra/Softwares/openfire/openfire_src/work/classes
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.5
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:3: error: package com.mysql.jdbc does not exist
[javac] import com.mysql.jdbc.Connection;
[javac] ^
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:4: error: package com.mysql.jdbc does not exist
[javac] import com.mysql.jdbc.PreparedStatement;
[javac] ^
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:5: error: package com.mysql.jdbc does not exist
[javac] import com.mysql.jdbc.ResultSet;
[javac] ^
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:21: error: cannot find symbol
[javac] PreparedStatement stat = (PreparedStatement)connect.prepareStatement(query2);
[javac] ^
[javac] symbol: class PreparedStatement
[javac] location: class UserDB
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:21: error: cannot find symbol
[javac] PreparedStatement stat = (PreparedStatement)connect.prepareStatement(query2);
[javac] ^
[javac] symbol: class PreparedStatement
[javac] location: class UserDB
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:21: error: cannot find symbol
[javac] PreparedStatement stat = (PreparedStatement)connect.prepareStatement(query2);
[javac] ^
[javac] symbol: method prepareStatement(String)
[javac] location: variable connect of type Connection
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:23: error: cannot find symbol
[javac] ResultSet result = (ResultSet) stat.executeQuery();
[javac] ^
[javac] symbol: class ResultSet
[javac] location: class UserDB
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:23: error: cannot find symbol
[javac] ResultSet result = (ResultSet) stat.executeQuery();
[javac] ^
[javac] symbol: class ResultSet
[javac] location: class UserDB
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:28: error: cannot find symbol
[javac] PreparedStatement preparedStmt = (PreparedStatement) connect.prepareStatement(query);
[javac] ^
[javac] symbol: class PreparedStatement
[javac] location: class UserDB
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:28: error: cannot find symbol
[javac] PreparedStatement preparedStmt = (PreparedStatement) connect.prepareStatement(query);
[javac] ^
[javac] symbol: class PreparedStatement
[javac] location: class UserDB
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:28: error: cannot find symbol
[javac] PreparedStatement preparedStmt = (PreparedStatement) connect.prepareStatement(query);
[javac] ^
[javac] symbol: method prepareStatement(String)
[javac] location: variable connect of type Connection
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:41: error: cannot find symbol
[javac] PreparedStatement statement = (PreparedStatement) connect.prepareStatement("Insert into user values (?,?,?);");
[javac] ^
[javac] symbol: class PreparedStatement
[javac] location: class UserDB
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:41: error: cannot find symbol
[javac] PreparedStatement statement = (PreparedStatement) connect.prepareStatement("Insert into user values (?,?,?);");
[javac] ^
[javac] symbol: class PreparedStatement
[javac] location: class UserDB
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:41: error: cannot find symbol
[javac] PreparedStatement statement = (PreparedStatement) connect.prepareStatement("Insert into user values (?,?,?);");
[javac] ^
[javac] symbol: method prepareStatement(String)
[javac] location: variable connect of type Connection
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:73: error: cannot find symbol
[javac] PreparedStatement statement = (PreparedStatement) connect.prepareStatement(query);
[javac] ^
[javac] symbol: class PreparedStatement
[javac] location: class UserDB
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:73: error: cannot find symbol
[javac] PreparedStatement statement = (PreparedStatement) connect.prepareStatement(query);
[javac] ^
[javac] symbol: class PreparedStatement
[javac] location: class UserDB
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:73: error: cannot find symbol
[javac] PreparedStatement statement = (PreparedStatement) connect.prepareStatement(query);
[javac] ^
[javac] symbol: method prepareStatement(String)
[javac] location: variable connect of type Connection
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:75: error: cannot find symbol
[javac] ResultSet result = (ResultSet) statement.executeQuery();
[javac] ^
[javac] symbol: class ResultSet
[javac] location: class UserDB
[javac] /home/rudra/Softwares/openfire/openfire_src/src/java/org/jivesoftware/openfire/UserDB.java:75: error: cannot find symbol
[javac] ResultSet result = (ResultSet) statement.executeQuery();
[javac] ^
[javac] symbol: class ResultSet
[javac] location: class UserDB
谁能帮我这个?