JDBConnection.java
上传用户:toby828
上传日期:2015-06-26
资源大小:8558k
文件大小:1k
- package com.tool;
- import java.sql.*;
- public class JDBConnection {
- private String dbDriver = "net.sourceforge.jtds.jdbc.Driver"; //数据库的驱动
- private String url = "jdbc:jtds:sqlserver://localhost:1433/db_shopping"; //URL地址
- public Connection connection = null;
- public JDBConnection() {
- try {
- Class.forName(dbDriver).newInstance(); //加载数据库驱动
- connection = DriverManager.getConnection(url, "sa", ""); //加载数据库
- }
- catch (Exception ex) {
- System.out.println("数据库加载失败");
- }
- }
- }