import java.sql.*;
class DbConnection {
public static void main(String args[]) throws Exception
{
//Registering the driver
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
//establish the connection with database
Connection con= DriverManager.getConnection("jdbc:oracle:thin:@194.16.247.96:1521:onlspn","onlinedbs", "onlinedbs");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select serno,amt_card from AUTHORIZATIONS where "
+ " SERNO > (select max(SERNO)-200 from AUTHORIZATIONS) and source "
+ "in ('VISA','MA01','MA02','MA03','MA10','MA11','MA12','AMA1','AMA2','AMP1','AMP2') order by serno desc");
while (rs.next()) {
int empid = rs.getInt("serno");
String fname = rs.getString("amt_card");
System.out.println(empid +'\t'+ fname);
}
}
}
專家幫我連接到我的遠程數據庫沒有合適的驅動程序找到了JDBC:神諭:薄錯誤
什麼JDBC jar文件在你的classpath上? – Andreas
ojdbc6.jar。由於我正在使用eclipse,所以我在那裏添加了jar也 –
無法重現。我得到'java.net.ConnectException:連接超時:connect',所以它正確地標識了'jdbc:oracle:thin'作爲JDBC驅動程序處理的JDBC URL。 – Andreas