日期:2014-05-20  浏览次数:20713 次

java 连接oracle 数据库问题
Connection conn = null;
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@172.16.2.229:1521:DBSERVER";
String UserName="root";
String PassWord ="root";
conn = DriverManager.getConnection(url,UserName,PassWord);

Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from insurance_accounts where name='胡军");
while(rs.next()){
rs.getString(0);
}
rs.close();
conn.close();


问题: rs.next 为false..是什么原因呢,有什么解决办法?

------解决方案--------------------
胡军缺单引号。
------解决方案--------------------
正解
探讨

ResultSet rs = stmt.executeQuery("select * from insurance_accounts where name like '%胡%'");
while(rs.next()){
System.out.println(rs.getString(0));
}

有东西输出么?