📄 odbc.java
字号:
/*
* 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -