-2
即时通讯寻求建立一个for循环的R [X] X是在前面的for循环的Java/SQL - For循环
的语法for循环心不是给我任何帮助,这都说明。
r是一个短路线,说它挑选R1,将对应于一个行中的数据库
所以X可以是1,2,3等。
那么,是否可以说对于(R [X])?
CODE:
for(int X = 1; X < records; X++) {
for(r[X]) {
//<editor-fold defaultstate="collapsed" desc="To check if RX is in Collision Table">
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
//load the oracle driver...needs to be in classes folder in jre folder
} catch (ClassNotFoundException e) {
System.out.println(
" Can't find class oracle.jdbc.driver.OracleDriver");
System.exit(1);
}
Connection conn5 = null;
//new connection object
Statement stmtFindRx = null;
//new statemnt object
ResultSet checkRx = null;
//new record set object
try {
conn5 = DriverManager.getConnection("jdbc:oracle:thin:@oracle.staff.ittralee.ie:1521:orcl",
"*", "*");
stmtFindRx = conn5.createStatement();
// create the statement for this connection
//</editor-fold>
checkRx = stmtFindRx.executeQuery(
"*********");
// get the results of select query and store in recordset object
while (checkRx.next()) {
// move to first/next record of recordset
JOptionPane.showMessageDialog(null, " the answer is " + checkRx.getString(1));
//JOptionPane.showMessageDialog(null, " the answer is " + fRoutes);
// output next record using string format
}
//<editor-fold defaultstate="collapsed" desc="Error handling for Select Statement">
checkRx.close();
checkRx = null;
stmtFindRx.close();
stmtFindRx = null;
conn5.close();
conn5 = null;
} catch (SQLException e) {
System.out.println(" A SQL error: " + e.getMessage());
} finally {
if (checkRx != null) {
try {
checkRx.close();
} catch (SQLException ignore) {
}
}
if (stmtFindRx != null) {
try {
stmtFindRx.close();
} catch (SQLException ignore) {
}
}
if (conn5 != null) {
try {
conn5.close();
} catch (SQLException ignore) {
}
}
}
// </editor-fold>
}
}
不要加载驱动程序或建立在回路中DB连接。做一次并重新使用连接,或使用连接池。 – Stefan 2012-03-14 14:51:57
这就是我现在正在做这个计划,它将在稍后解决 – user1081326 2012-03-14 14:53:26
你能显示定义“r”的代码吗? – 2012-03-14 14:57:51