이 기사에서 편집자는 주로 Java가 Oracle, DB2, SQL Server, Sybase, MySQL, PostgreSQL 및 기타 데이터베이스에 연결하는 방법을 주로 소개합니다.
1. Oracle 데이터베이스
class.forname ( "oracle.jdbc.driver.oracledriver". NewInstance (); "test"; String ";"Test ";
2. DB2 데이터베이스
class.forname ( "com.ibm.db2.jdbc.app.db2driver") .newinstance (); : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : "admin"; ;
3. SQL Server 데이터베이스
class.forname ( "com.microsoft.jdbc.sqlserver.sqlserverdriver") user = "sa"; String password = "";
4. Sybase 데이터베이스
class.forname ( "com.sybase.jdbc.sybdriver"). NewInstance (); (); sysprops.puts.put ( "password", "user_password";
5. MySQL 데이터베이스
class.forname ( "org.gjt.mm.mysql.driver"). NewInstance (); "JDBC : mysql : // localhost/mydb? user = soft1234 & us eunicode = true & caracterEncoding = 8859_1"// mydb 데이터베이스 연결 Conn = DriverManager.GetConnection (URL);
6. PostgreSQL 데이터베이스
class.forname ( "org.postgresql.driver". newInstance (); "JDBC : // localhost/mydb"// mydb는 데이터베이스 이름 string user = "myuser"; MyPassword "; Connection Conn = DriverManager.GetConnection (URL, USER, PASSFARPT);
위의 것은 Java를 다양한 데이터베이스에 연결하기위한 팁입니다.