找回密码
 立即注册
getStringrscloseStringdburl | 企业管理 2022-09-22 100 0star收藏 版权: . 保留作者信息 . 禁止商业使用 . 禁止修改作品
闲来无事,整理了一下Java代码。算做个复习笔记了。
importjava.sql.
;
publicclassdbAccess{
publicstaticvoidmain(Stringargs)throwsException{
Class.forName(sun.JDBC.odbc.JdbcOdbcDriver);
Stringdburl=jdbc<imgsrc="static/image/smiley/default/shocked.gif"smilieid="6"border="0"alt=""/>dbc:driver={MicrosoftAccessDriver(
.mdb)};DBQ=Mobile.mdb;//此为NO-DSN方法
//Stringdburl=jdbc<imgsrc="static/image/smiley/default/shocked.gif"smilieid="6"border="0"alt=""/>dbc<imgsrc="static/image/smiley/default/shocked.gif"smilieid="6"border="0"alt=""/>dbcName;//此为ODBC连接方法
Connectionconn=DriverManager.getConnection(dburl);
Statementstmt=conn.createStatement();
ResultSetrs=stmt.executeQuery(selectTop20
fromMobileSection);
System.out.println(号段\t地区\t类型\t份\t区号);
while(rs.next()){
System.out.println(rs.getString(1)+\t+rs.getString(2)+\t+rs.getString(3)+\t+rs.getString(4)+\t+rs.getString(5));
}
rs.close();
stmt.close();
conn.close();
}
}


(When I have nothing to do, I sorted out the Java code. It's a review note.
importjava.sql.
;
publicclassdbAccess{
publicstaticvoidmain(Stringargs)throwsException{
Class.forName(sun.JDBC.odbc.JdbcOdbcDriver);
Stringdburl=jdbc<imgsrc="static/image/smiley/default/shocked.gif"smilieid="6"border="0"alt=""/>dbc:driver={MicrosoftAccessDriver(
.mdb)};DBQ=Mobile.mdb;//This is the NO-DSN method
//Stringdburl=jdbc<imgsrc="static/image/smiley/default/shocked.gif"smilieid="6"border="0"alt=""/>dbc<imgsrc="static/image/smiley/default/ shocked.gif"smilieid="6"border="0"alt=""/>dbcName;//This is the ODBC connection method
Connectionconn=DriverManager.getConnection(dburl);
Statementstmt=conn.createStatement();
ResultSetrs=stmt.executeQuery(selectTop20
fromMobileSection);
System.out.println(number segment\t area\t type\t copy\t area code);
while(rs.next()){
System.out.println(rs.getString(1) \t rs.getString(2) \t rs.getString(3) \t rs.getString(4) \t rs.getString( 5));
}
rs.close();
stmt.close();
conn.close();
}
})

[下载]22301129250.rar




上一篇:Java连接各种数据库的实例
下一篇:无错JSP网上书店源代码