testcon.jsp
资源名称:0102010.rar [点击查看]
上传用户:nbluoke
上传日期:2013-08-09
资源大小:4851k
文件大小:1k
源码类别:
教育系统应用
开发平台:
WORD
- <%@ page contentType="text/html; charset=gb2312" language="java" %>
- <%@ page import="java.sql.*" %>
- <%
- Connection con = null;
- Statement stmt = null;
- ResultSet rs = null;
- String DRIVER = "com.mysql.jdbc.Driver";
- String USERNAME = "cbd";
- String PASSWORD = "cbdcosoft@1";
- String CONNECTION_STRING = "jdbc:mysql://localhost/jsptestonline";
- try {
- Driver DriverJinghua = (Driver) Class.forName(DRIVER).newInstance();
- //Con = DriverManager.getConnection(CONNECTION_STRING,USERNAME,PASSWORD);
- }
- catch (ClassNotFoundException e) {
- out.println(" 1 Connection Driver Error: classNotFoundException");
- out.println(e.toString() );
- }
- catch (Exception e) {
- out.println("2 Connection Driver Error: Exception");
- out.println(e.toString() );
- }
- try {
- //Con = DriverManager.getConnection(CONNECTION_STRING,USERNAME,PASSWORD);
- String strUrl = CONNECTION_STRING + "?user=" + USERNAME +
- "&password=" +
- PASSWORD + "&useUnicode=true&characterEncoding=gb2312";
- con = DriverManager.getConnection(strUrl);
- out.println("########Conncetion OK!");
- }
- catch (Exception e) {
- con = null;
- out.println("3 Connection Error");
- out.println(e.toString() );
- }
- finally{
- con=null;
- }
- %>