文件名称:
Mysql,SQL Server 2000,Oracle四种数据库的连接
开发工具:
文件大小: 1mb
下载次数: 0
上传时间: 2008-12-10
详细说明: <%! String trans(String chi) { String result = null; byte temp []; try { temp=chi.getBytes("iso-8859-1"); result = new String(temp); } catch(UnsupportedEncodingException e) { System.out.println (e.toString()); } return result; } %> <% Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInsta nce(); Connection con=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=books","sa",""); Statement stmt=con.createStatement(); ResultSet rst=stmt.executeQuery("select * from book"); while(rst.next()) { out.println(""); out.println(""+rst.getString("bookId")+" | "); out.println(""+trans(rst.getString("bookName"))+" | "); out.println(""+trans(rst.getString("publisher"))+" | "); out.println(""+rst.getFloat("price")+" | "); out.println("
"); } //关闭连接、释放资源 rst.close(); stmt.close(); con.close(); %>