Connection conn = null;
Statement stmt=null;
ResultSet rset=null;
String jdbc_url="jdbc:oracle:thin:hr/hr@bassam-desktop:1521:XE";
String query="";
try
{
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn=DriverManager.getConnection(jdbc_url);
stmt=(Statement) conn.createStatement();
query="select first_name" +"from employees"+"where employeed_id=100";
rset=stmt.executeQuery(query);
System.out.println(rset.getString(1));
}
catch(SQLException | NumberFormatException e)
{
System.out.println("result error");
}
finally{
try{
rset.close();
stmt.close();
conn.close();
}
catch(Exception e)
{
System.out.println("Error in closing");
}
}
我在结果窗口中同时出现两个错误,这是什么问题?hr密码是正确的,我的主机名是正确的,是不是你在windows xp中右击“我的电脑”后从“计算机名”得到的那个?
编辑:使用 e.getMessage() 后,我得到了这个..
result error, ResultSet.next was not called