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);
}
}
}
伙计们帮助我连接到我的远程数据库
答案 0 :(得分:1)
我已经在类路径上使用ojdbc6.jar尝试了你的代码,它编译并运行正常。 但是,当您运行代码时,它无法找到合适的驱动程序。这可能意味着两件事: