direct-access.jsp
资源名称:examasp.rar [点击查看]
上传用户:hjt198082
上传日期:2015-04-16
资源大小:95k
文件大小:1k
源码类别:
MySQL数据库
开发平台:
Java
- <%@ page contentType="text/html;charset=gb2312"%>
- <%@ page import="java.sql.*"%>
- <%
- Connection con;
- Statement stmt;
- try{
- //Load JDBC driver
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- //注意DBQ的写法
- String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=g:\db1.mdb";//注意在Driver 和(*.mdb)之间要有一个空格!
- con = DriverManager.getConnection(url);
- //if(true){out.println("aaaaaaaaa");
- //return;}
- stmt = con.createStatement();
- String query ="select * from guest";
- ResultSet rs = stmt.executeQuery(query);
- while(rs.next())
- {
- String str = rs.getString("name");
- out.print(str+"<br>");
- }
- }
- catch(Exception e){
- e.printStackTrace();
- e.toString();
- if(true)out.println("bbbbbbb");
- return;
- }
- %>