Java database connection interface (JDBC) is a set of Apis defined in Java for database connection and operations. Different database vendors provide implementation classes for this interface. For Java programmers, they do not need to care about the underlying implementation of the database, the abstract APIs in JDBC are called to implement database access functions in a unified manner. In the data access function and interface definition, Java is ideal in other languages, what programmers need is to know the different JDBC implementation of each database, that is, the driver, and the description of the Database URL, everything else is implemented through unified calls. This article collects the drivers and URLs provided by major database vendors so that you can easily connect to various databases.
Uniform usage in JDBC
Class. For (jdbcdrivername );
Connection conn = drivermanager. getconnection (URL, user, password );
The interfaces here are unified. The difference is that the jdbcdriver and URL provided by each database are different.
Let's take a look.
MySQL
Class. forname ("com. MySQL. JDBC. Driver ");
Connection con = drivermanager. getconnection ("JDBC: mysql: // host: Port/Database", "user", "password ");
Oracle Database (thin Mode)
Class. forname ("oracle. JDBC. Driver. oracledriver ");
Connection con = drivermanager. getconnection ("JDBC: oracle: thin: @ host: Port: Databse", "user", "password ");
Timesten database (thin Mode)
Class. forName ("com. timesten. jdbc. TimesTenDriver ");
Connection con = DriverManager. getConnection ("jdbc: timesten: client: dsn = dsnname ")
Microsoft SQL Server
Class. forName ("net. sourceforge. jtds. jdbc. Driver ");
Connection con = DriverManager. getConnection ("jdbc: jtds: sqlserver: // host: port/database", "user", "password ");
Or
Connection con = DriverManager. getConnection ("jdbc: jtds: sybase: // host: port/database", "user", "password ");
DB2
Class. forName ("com. ibm. db2.jdbc. app. DB2Driver ");
Connection conn = DriverManager. getConnection ("jdbc: db2: // localhost: 5000/sample", user, password );
Firebird
Class. forName ("org. firebirdsql. jdbc. FBDriver ");
Connection con = DriverManager. getConnection ("jdbc: firebirdsql: // host: port/fdb_file_path", "user", "password ");
PointBase (Server)
Class. forname ("com. pointbase. JDBC. jdbcuniversaldriver ");
Connection con = drivermanager. getconnection ("JDBC: pointbase: SERVER: // host: Port/databasename", "user", "password ");
HSQLDB (Server)
Class. forname ("org. HSQLDB. jdbcdriver ");
Connection con = drivermanager. getconnection ("JDBC: HSQLDB: hsql: // localhost: Port/mydb", "user", "password ");
Derby
Few people have heard of this. cloudscape should have heard of it. This project is derived from this.
Class. forname ("org. Apache. Derby. JDBC. clientdriver ");
Connection con = drivermanager. getconnection ("JDBC: Derby: // host: Port // mydb", "user", "password ");
Class. forname ("org. Apache. Derby. JDBC. embeddeddriver ");
Connection conn = drivermanager. getconnection ("JDBC: Derby: mynewdb", P );
Cloudscape
Class. forname ("com. cloudscape. Core. jdbcdriver ");
Connection conn = drivermanager. getconnection ("JDBC: cloudscape: <dB> ");
Class. forName ("com. cloudscape. rmiJdbc. Alibaba driver ");
Connection conn = DriverManager. getConnection ("jdbc: rmi: // <HOST >:< PORT>/jdbc: cloudscape: <DB>", user, passoword );
Postgresql
Class. forName ("org. postgresql. Driver ");
Connection con = DriverManager. getConnection ("jdbc: postgresql: // host: port/database", "user", "password ");
Informix
Class. forName ("com. informix. jdbc. IfxDriver"). newInstance ();
Connection con = DriverManager. getConnection ("jdbc: informix-sqli: // host: port/myDB: INFORMIXSERVER = myserver", "user", "password ");
Access
Class. forName ("sun. jdbc. odbc. JdbcOdbcDriver ");
Connection con = DriverManager. getConnection ("jdbc: odbc: Driver = {MicroSoft Access Driver (*. mdb)}; DBQ = mdb file path "," user "," password ");
Sybase
Class. forName ("com. sybase. jdbc2.jdbc. SybDriver"). newInstance ();
Connection con = DriverManager. getConnection ("jdbc: sybase: Tds: host: port? ServiceName = databasename "," user "," password ");
=========================== Additional ============================== =
JDBC syntax used by the IBM AS400 host
Class. forName ("com. ibm. as400.access. AS400JDBCConnection ");
Connection con = DriverManager. getConnection ("jdbc: as400: // IP", "user", "passwor ");
Sapdb
Class. forName ("com. sap. dbtech. jdbc. DriverSapDB ");
Connection con = DriverManager. getConnection ("jdbc: sapdb: // host: port/DB_NAME", "user", "passwor ");
SS
Class. forName ("com. progress. SQL. jdbc. JdbcProgressDriver ");
Connection con = DriverManager. getConnection ("jdbc: JdbcProgress: T: dbserver: 3305: liveappl", "user", "passwor ");
Mimer SQL Local
Class. forName ("com. mimer. jdbc. Driver ");
Connection con = DriverManager. getConnection ("jdbc: mimer: multi1", "user", "passwor ");
Altibase
Memory Database
Class. forName ("Altibase. jdbc. driver. AltibaseDriver ");
Connection con = DriverManager. getConnection ("jdbc: Altibase: // host: port/dbname", "user", "passwor ");
Solid DB
Is there any impression above? If I keep paying attention to my article, I mentioned the two in my lecture Timesten. There is also an eXtremeDB without JDBC support.
Class. forName ("solid. jdbc. SolidDriver ");
Connection con = DriverManager. getConnection ("jdbc: solid: // yourdbhost: 1964/yourdbusername/yourdbpassword ");