请教高手 java 内连接查询语句无法显示结果 SQL语句替换为:select * from do 就能输出结果,
packagejo;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.Resul...
package jo;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.Statement;import java.util.ArrayList;import java.util.Date;import java.util.List;public class joFactory { public static List<joEntity> getPeoples() { List<joEntity> list = new ArrayList<joEntity>(); Connection conn = null; try { String url = "jdbc:oracle:thin:@192.168.1.121:1521:ORCL"; Class.forName("oracle.jdbc.driver.OracleDriver"); conn = DriverManager.getConnection(url,"concrete","concrete"); Statement stm = conn.createStatement(); String sql = "select t.*,p.* from DO t,doprod p where indate > to_date('2017/05/06 06:00:00','YYYY/MM/DD HH24:MI:SS') and indate < to_date('2017/05/06 09:00:00','YYYY/MM/DD HH24:MI:SS')"; ResultSet rs = stm.executeQuery(sql); //select t.*,p.* from DO t,doprod p where indate > to_date('2017/05/06 06:00:00','YYYY/MM/DD HH24:MI:SS') and indate < to_date('2017/05/06 09:00:00','YYYY/MM/DD HH24:MI:SS'); while (rs.next()) { joEntity o = new joEntity(); o.setdoid(rs.getString("doid")); //0 o.setsoid(rs.getString("soid")); //1 list.add(o); } rs.close(); stm.close(); conn.close(); } catch (Exception e) { e.printStackTrace(); } return list; } }
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询