odbc.java

来自「用java 实现的IE browser适合于学者」· Java 代码 · 共 44 行

JAVA
44
字号
/*
 * Created on 2004-6-24
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.hnjchina.securityView;
import	java.sql.*;
/**
 * @author limeiyong
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class Odbc {
public	static	void main(String[] string){
	try {
		//load jdbc driver
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		String	dbUrl="jdbc:odbc:driver={Adaptive Server Anywhere 7.0};DBQ=lottery.db";
		try {
			Connection	con=DriverManager.getConnection(dbUrl,"dba","sql");
			Statement	state=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
			String		sql="select * from	employee";
			ResultSet	rs=state.executeQuery(sql);
			int			li_row=0;
			if	(rs!=null){
				while (rs.next()){
					li_row=rs.getRow();
					System.out.println("\t"+rs.getString("Empnach"));
				}
			}
			rs.close();
			con.close();
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	} catch (ClassNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}	
}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?