我编写此代码是为了将数据存储在数据库中并使用NetBeans程序查看结果。但是没有输出,也没有编译错误。我能知道是什么问题吗?有没有缺少的jar文件
package database;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.*;
public class Database {
static Connection conn;
public Database() {
}
public static Connection getConnection() {
return conn;
}
public static void main(String[] args) throws SQLException {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
System.out.println("Could not load the driver");
}
String user = "SYSTEM"; //readEntry("Enter userid: ");
String pass = "mevooo";//readEntry("Enter password: ");
conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", user, pass);
String query = "select Ref, Title,Risk_Rating, Root_cause, Impact, Likelihood, Efforts, Finding, Implication, Recommendation from Lack_Of_Defense ";
PreparedStatement myStatement = conn.prepareStatement(query);
myStatement.clearParameters();
ResultSet myResult = myStatement.executeQuery(query);
while (myResult.next()) {
String Ref = myResult.getString(1);
String Title = myResult.getString(2);
String Risk_Rating = myResult.getString(3);
String Root_cause = myResult.getString(4);
String Impact = myResult.getString(5);
String Likelihood = myResult.getString(6);
String Efforts = myResult.getString(7);
String Finding = myResult.getString(8);
String Implication = myResult.getString(9);
String Recommendation = myResult.getString(10);
System.out.println(" =============================================================");
System.out.println(" ===================== Lack of defense Table ==================");
System.out.println(" Ref : " + Ref);
System.out.println(" Title " + Title);
System.out.println(" Risk Rating " + Risk_Rating);
System.out.println(" Root cause " + Root_cause);
System.out.println(" Impact " + Impact);
System.out.println(" Likelihood " + Likelihood);
System.out.println(" Efforts " + Efforts);
System.out.println(" Finding " + Finding);
System.out.println(" Implication " + Implication);
System.out.println(" Recommendation " + Recommendation);
}
}
}