DataConnect.java
资源名称:Jason.rar [点击查看]
上传用户:wok5188
上传日期:2018-02-20
资源大小:1835k
文件大小:1k
源码类别:
MySQL数据库
开发平台:
Java
- package com.center.commons;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class DataConnect {
- private Connection conn;
- public DataConnect(){
- try {
- Class.forName("com.mysql.jdbc.Driver");
- try {
- conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/shopingcenter", "root", "mengxia");
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public Connection getConn(){
- return conn;
- }
- }