R多变量正态性检验(Multivariate Normality Tests)

Java注解和反射 03 反射概念获得反射对象

  返回  

jdbc实现查询

2021/7/21 7:49:36 浏览:
public static void main(String args[]) {
	Scanner scan = new Scanner(System.in);
	System.out.print("输入用户id:");
	String consId = null;
	if (scan.hasNextLine()) {
		consId = scan.nextLine();

	}
	String orgNo = null;
	System.out.print("输入供电单位:");
	if (scan.hasNextLine()) {
		orgNo = scan.nextLine();

	}
	DataBaseGetConect a = new DataBaseGetConect();
	a.getConnect();
}

public void getConnect() {
	try {
		Class.forName("oracle.jdbc.OracleDriver");
	} catch (ClassNotFoundException e) {
		System.out.println("找不到驱动程序类 ,加载驱动失败!");
		e.printStackTrace();
	}

	String url = "jdbc:oracle:thin:@10.4.59.29:1521/epmsc95";
	// Properties info = new Properties();
	Long consId = null;// 4115001008l;
	String orgNo = "51411";
	StringBuffer sql = new StringBuffer("select * from c_cons where 1=1");
	List params = new ArrayList();
	if (consId != null) {
		sql.append(" and cons_id = ?");
		params.add(consId);
	}
	if (orgNo != null && !"".equals(orgNo)) {
		sql.append(" and org_no = ?");
		params.add(orgNo);
	}
	PreparedStatement pstmt = null;
	Connection connection = null;
	try {
		connection = DriverManager.getConnection(url, "epm_sc", "neusoft");
		pstmt = connection.prepareStatement(sql.toString());
		Iterator iterator = params.iterator();
		int i = 0;
		while (iterator.hasNext()) {
			i += 1;
			pstmt.setObject(i, iterator.next());
		}

		ResultSet rs = pstmt.executeQuery();
		if (rs != null) {
			int size = 0;
			while (rs.next()) {
				size++;
			}
			System.out.println(size);
		}
		System.out.println("啊     aaa  啊啊啊啊  啊啊啊啊啊");
		while (rs.next()) {
			System.out.println(rs.getString("cons_name"));
		}
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} finally {
		if (pstmt != null) { // 关闭声明
			try {
				pstmt.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if (connection != null) { // 关闭连接对象
			try {
				connection.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}

}
// Class.forName("com.mysql.jdbc.Driver");

联系我们

如果您对我们的服务有兴趣,请及时和我们联系!

服务热线:18288888888
座机:18288888888
传真:
邮箱:888888@qq.com
地址:郑州市文化路红专路93号