1. apt-get install  libmysql-java

2. 環境變數 CLASSPATH 新增 /usr/share/java/mysql-connector-java.jar

3. 寫個code測試

import java.sql.Connection;
import java.sql.DriverManager;

class JDBCTest {

	private static final String url = "jdbc:mysql://localhost";

	private static final String user = "username";

	private static final String password = "password";

	public static void main(String args[]) {
		try {
			Connection con = DriverManager.getConnection(url, user, password);
			System.out.println("Success");

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

slv922 發表在 痞客邦 PIXNET 留言(0) 人氣()