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