package com.lxx.TESTdemo; import java.sql.*; public class Dbconn { public static String url = "jdbc:mysql://localhost:3306/test"; public static String root = "root"; public static String password = "123456"; public static Connection conn; public static Connection getConn(){ try{ Class.forName("org.gjt.mm.mysql.Driver").newInstance(); System.out.println("driver success!"); conn = DriverManager.getConnection(url, root, password); System.out.println("连接成功!"); }catch (Exception e){ e.printStackTrace(); System.out.println("连接失败"); } return conn; }; }
全部评论
(4) 回帖