package com.offcn.TestUnti;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class MYSQLConnection {
	
	public static Connection coontSql(String url,String name,String pwd){
		Connection ct=null;
		try {
			Class.forName("com.mysql.jdbc.Driver");
			ct = DriverManager.getConnection(url, name,pwd);
		} catch (ClassNotFoundException e) {
			System.out.println("获取驱动失败");
			e.printStackTrace();
		} catch (SQLException e) {
			System.out.println("建立连接失败");
			e.printStackTrace();
		}
		return ct;
	}
	
	public static Statement stmtSql(Connection ct){
		Statement stmt = null;
		try {
			stmt = ct.createStatement();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return stmt;
	}

}
