ตัวอย่าง JDBC Connection Driver

Note ไว้กันลืมครับ รูปแบบ JDBC Driver ต่างๆ ของ Database แต่ละตัว
Database Name : Apache Derby(embedded database)

driver-class : org.apache.derby.jdbc.EmbeddedDriver
connection-url : jdbc:derby:[dbname];[Property List]
connection-url : jdbc:derby://[host]/[dbname];[Property List]
example : jdbc:derby:testdb;create=true
example : jdbc:derby://localhost/testdb;create=true

Database Name : DB2

driver-class : com.ibm.db2.jcc.DB2Driver
connection-url : jdbc:db2://[host]:[port]/[dbname]
example : jdbc:db2://localhost:50000/sample

Database Name : Firebird

driver-class : org.firebirdsql.jdbc.FBDriver
connection-url : jdbc:firebirdsql:[host]/[port]:[path to db(*.fdb)]
example : jdbc:firebirdsql:localhost/3050:C:/testdb.fdb

Database Name : Hypersonic (embedded database)

driver-class : org.hsqldb.jdbcDriver
connection-url : (Memory) jdbc:hsqldb:mem:[dbname]
connection-url : (Standalone) jdbc:hsqldb:file:[path to db]
connection-url : (DB Server) jdbc:hsqldb://localhost/[dbname]
example : (Memory) jdbc:hsqldb:mem:testdb
example : (Standalone) jdbc:hsqldb:file:C:/testdb
example : (DB Server) jdbc:hsqldb://localhost/testdb


Database Name : Oracle

driver-class : oracle.jdbc.driver.OracleDriver
connection-url : jdbc:oracle:thin:@[host]:[port]:[sid]
example : jdbc:oracle:thin:@localhost:1525:XE

Database Name : Informix

Class : com.informix.jdbc.IfxDriver
connection-url : jdbc:informix-sqli://[host][port]:/[dbname]:INFORMIXSERVER=[servername]
example : jdbc:informix-sqli://localhost:1542/testdb:INFORMIXSERVER=server1

Database Name : Microsoft SQL Server

driver-class : com.microsoft.sqlserver.jdbc.SQLServerDriver
connection-url : (2005) jdbc:sqlserver://[host]:[port];databaseName=[dbname]
connection-url : (2000) jdbc:microsoft:sqlserver://[host]:[port];databaseName=[dbname]
example : (2005) jdbc:sqlserver://localhost:1433;databaseName=testdb
example : (2000) jdbc:microsoft:sqlserver://localhost:1433;databaseName=testdb

Database Name : MySQL

driver-class : com.mysql.jdbc.Driver
connection-url : jdbc:mysql://[host]:[port]/[dbname]
example : jdbc:mysql://localhost:3306/testdb

Database Name : PostgreSQL

driver-class : org.postgresql.Driver
connection-url : jdbc:postgresql://[host]:[port]/[dbname]
example : jdbc:postgresql://localhost:5432/testdb

Database Name : SAP Db

driver-class : com.sap.dbtech.jdbc.DriverSapDB
connection-url : jdbc:sapdb://[host]/[dbname]
example : jdbc:sapdb://localhost/testdb
Web Site : http://www.sapdb.org/jdbcSapdbcEng.html

Database Name : Sybase

driver-class : com.sybase.jdbc2.jdbc.SybDataSource
connection-url : jdbc:sybase:Tds:[host]:[port]/[dbname]
example : jdbc:sybase:Tds:localhost:3697/testdb

ตัวอย่าง Code สำหรับติดต่อฐานข้อมูล

public Connection getConnection() {		
	Connection conn = null;
	try {
		Class.forName("com.mysql.jdbc.Driver");
		conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/testdb","root","java");
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
	} catch (SQLException e) {
		e.printStackTrace();
	}		
	retrun conn;
}

หมายเหตุ :
ข้อมูลอาจไม่ถูกต้องและไม่ครบถ้วน กรุณาตรวจสอบก่อนใช้งาน เนื่องจากผมไม่ได้ทดสอบทุกตัวนะครับ
JDBC Driver

    • suwaj
    • March 11th, 2010

    ขอบคุณครับ กำลังหาข้อมูลอยู่พอดี ครับ
    จะใช้ open office base coneect เข้าไปทำงาน ที่ database mysql
    ครับ

  1. Thanks on your maгvelous posting! I gеnuinely enjߋyed rеading it, you could be a great author.I
    will always boοkmark your blog and will eventually come baϲk
    later in life. I want to encoᥙrage one to continue yoսr
    great writіng, have a nice evening!