1
MySQL:
2
String Driver="com.mysql.jdbc.Driver"; //驅(qū)動(dòng)程序
3
String URL="jdbc:mysql://localhost:3306/db_name"; //連接的URL,db_name為數(shù)據(jù)庫(kù)名
4
String Username="username"; //用戶(hù)名
5
String Password="password"; //密碼
6
Class.forName(Driver).new Instance();
7
Connection con=DriverManager.getConnection(URL,Username,Password);
8
Microsoft SQL Server 2.0驅(qū)動(dòng)(3個(gè)jar的那個(gè)):
9
String Driver="com.microsoft.jdbc.sqlserver.SQLServerDriver"; //連接SQL數(shù)據(jù)庫(kù)的方法
10
String URL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_name"; //db_name為數(shù)據(jù)庫(kù)名
11
String Username="username"; //用戶(hù)名
12
String Password="password"; //密碼
13
Class.forName(Driver).new Instance(); //加載數(shù)據(jù)可驅(qū)動(dòng)
14
Connection con=DriverManager.getConnection(URL,UserName,Password); //
15
Microsoft SQL Server 3.0驅(qū)動(dòng)(1個(gè)jar的那個(gè)): // 老紫竹完善
16
String Driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"; //連接SQL數(shù)據(jù)庫(kù)的方法
17
String URL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_name"; //db_name為數(shù)據(jù)庫(kù)名
18
String Username="username"; //用戶(hù)名
19
String Password="password"; //密碼
20
Class.forName(Driver).new Instance(); //加載數(shù)據(jù)可驅(qū)動(dòng)
21
Connection con=DriverManager.getConnection(URL,UserName,Password); //
22
Sysbase:
23
String Driver="com.sybase.jdbc.SybDriver"; //驅(qū)動(dòng)程序
24
String URL="jdbc:Sysbase://localhost:5007/db_name"; //db_name為數(shù)據(jù)可名
25
String Username="username"; //用戶(hù)名
26
String Password="password"; //密碼
27
Class.forName(Driver).newInstance();
28
Connection con=DriverManager.getConnection(URL,Username,Password);
29
Oracle(用thin模式):
30
String Driver="oracle.jdbc.driver.OracleDriver"; //連接數(shù)據(jù)庫(kù)的方法
31
String URL="jdbc:oracle:thin:@loaclhost:1521:orcl"; //orcl為數(shù)據(jù)庫(kù)的SID
32
String Username="username"; //用戶(hù)名
33
String Password="password"; //密碼
34
Class.forName(Driver).newInstance(); //加載數(shù)據(jù)庫(kù)驅(qū)動(dòng)
35
Connection con=DriverManager.getConnection(URL,Username,Password);
36
PostgreSQL:
37
String Driver="org.postgresql.Driver"; //連接數(shù)據(jù)庫(kù)的方法
38
String URL="jdbc:postgresql://localhost/db_name"; //db_name為數(shù)據(jù)可名
39
String Username="username"; //用戶(hù)名
40
String Password="password"; //密碼
41
Class.forName(Driver).newInstance();
42
Connection con=DriverManager.getConnection(URL,Username,Password);
43
DB2:
44
String Driver="com.ibm.db2.jdbc.app.DB2.Driver"; //連接具有DB2客戶(hù)端的Provider實(shí)例
45
//String Driver="com.ibm.db2.jdbc.net.DB2.Driver"; //連接不具有DB2客戶(hù)端的Provider實(shí)例
46
String URL="jdbc:db2://localhost:5000/db_name"; //db_name為數(shù)據(jù)可名
47
String Username="username"; //用戶(hù)名
48
String Password="password"; //密碼
49
Class.forName(Driver).newInstance();
50
Connection con=DriverManager.getConnection(URL,Username,Password);
51
Informix:
52
String Driver="com.informix.jdbc.IfxDriver";
53
String URL="jdbc:Informix-sqli://localhost:1533/db_name:INFORMIXSER=myserver"; //db_name為數(shù)據(jù)可名
54
String Username="username"; //用戶(hù)名
55
String Password="password"; //密碼
56
Class.forName(Driver).newInstance();
57
Connection con=DriverManager.getConnection(URL,Username,Password);
58
JDBC-ODBC:
59
String Driver="sun.jdbc.odbc.JdbcOdbcDriver";
60
String URL="jdbc:odbc:dbsource"; //dbsource為數(shù)據(jù)源名
61
String Username="username"; //用戶(hù)名
62
String Password="password"; //密碼
63
Class.forName(Driver).newInstance();
64
Connection con=DriverManager.getConnection(URL,Username,Password);
65

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65
