求救ORCALCE问题
我用JAVA 连ORACLE 9.2.1 代码如下:
public static void main(String[] args) {
Connection con = null;
PreparedStatement pstat = null;
ResultSet rs = null;
String sql;
try {
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
con = DriverManager.getConnection(
"jdbc:oracle:thin:@172.29.254.188:1521:dbtest1", "scott",
"tiger");
if (con == null) {
System.out.println("NULL");
}
sql = "Select* from STUDENT";
pstat = con.prepareStatement(sql);
rs = pstat.executeQuery();
System.out.println("rs is " + rs);
while (rs.next()) {
System.out.println(rs.getString("NAME"));
}
/* rs.absolute(1);
System.out.println(rs.getInt("NUMBER"));
System.out.println(rs.getString("NAME"));*/
/*
* while(rs.next()){
*
* System.out.println(rs.getString("NAME")); }
*/
} catch (
SQLException e) {
System.out.println("Can't connect to db!");
e.printStackTrace();
} catch (
InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (
IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (
ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
rs.close();
pstat.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
在别人机器上rs都能取到值,而在我这取不到 rs.next()报了
ORA-01009: missing mandatory parameter
这个错误,不知道怎么回事,望高手帮忙解决一下;
------解决方案--------------------sql = "Select* from STUDENT";
改成
sql = "Select NAME from STUDENT";
------解决方案--------------------http://www.itpub.net/thread-134614-1-1.html
看下这个