Java连接Mysql问题
提示: 作者被禁止或删除 内容自动屏蔽
package com.hongtoo.crm; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; /** * 数据库连接 * @author Administrator * */ public class SQLConnection { private static String DRIVER = "com.mysql.jdbc.Driver"; private static String URL = "jdbc:mysql://192.168.1.24:3306/crm1"; private static String USERNAME ="root"; private static String PASSWORD = "7_dw42503pes"; /** * 获得连接 * @return * @throws Exception */ public static Connection getConn() throws Exception{ Class.forName(DRIVER); Connection conn=DriverManager.getConnection(URL, USERNAME, PASSWORD); return conn; } /** * 关闭连接 * @param conn * @throws SQLException */ public void closeConn(Connection conn) throws SQLException{ conn.close(); } public static void main(String[] args) throws Exception{ /** * 打印连接 */ System.out.println(getConn()); } }