JDBC connection method for various databases

2011-05-14  来源:本站原创  分类:Database  人气:99 

1, Oracle8/8i/9i database (thin model)

Class.forName ("oracle.jdbc.driver.OracleDriver"). NewInstance ();
String url = "jdbc: oracle: thin: @ localhost: 1521: orcl";
/ / Orcl SID for the database
String user = "test";
String password = "test";
Connection conn = DriverManager.getConnection (url, user, password);

2, DB2 database

Class.forName ("com.ibm.db2.jdbc.app.DB2Driver"). NewInstance ();
String url = "jdbc: db2: / / localhost: 5000/sample";
/ / Sample for your database name
String user = "admin";
String password = "";
Connection conn = DriverManager.getConnection (url, user, password);

3, Sql Server7.0/2000 database

Class.forName ("com.microsoft.jdbc.sqlserver.SQLServerDriver"). NewInstance ();
String url = "jdbc: microsoft: sqlserver: / / localhost: 1433; DatabaseName = mydb";
/ / Mydb database
String user = "sa";
String password = "";
Connection conn = DriverManager.getConnection (url, user, password);

4, Sybase Database

Class.forName ("com.sybase.jdbc.SybDriver"). NewInstance ();
String url = "jdbc: sybase: Tds: localhost: 5007/myDB";
/ / MyDB name for your database
Properties sysProps = System.getProperties ();
SysProps.put ("user", "userid");
SysProps.put ("password", "user_password");
Connection conn = DriverManager.getConnection (url, SysProps);

5, Informix Database

Class.forName ("com.informix.jdbc.IfxDriver"). NewInstance ();
String url =
"Jdbc: informix-sqli: / / 123.45.67.89:1533 / myDB: INFORMIXSERVER = myserver;
user = testuser; password = testpassword ";
/ / MyDB name for the database
Connection conn = DriverManager.getConnection (url);

6, MySQL database

Class.forName ("org.gjt.mm.mysql.Driver"). NewInstance ();
String url = "jdbc: mysql: / / localhost / myDB? User = soft & password = soft1234 & useUnicod
e = true & characterEncoding = 8859_1 "
/ / MyDB name for the database
Connection conn = DriverManager.getConnection (url);

7, PostgreSQL Database

Class.forName ("org.postgresql.Driver"). NewInstance ();
String url = "jdbc: postgresql: / / localhost / myDB"
/ / MyDB name for the database
String user = "myuser";
String password = "mypassword";
Connection conn = DriverManager.getConnection (url, user, password);

相关文章
  • JDBC connection method for various databases 2011-05-14

    1, Oracle8/8i/9i database (thin model) Class.forName ("oracle.jdbc.driver.OracleDriver"). NewInstance (); String url = "jdbc: oracle: thin: @ localhost: 1521: orcl"; / / Orcl SID for the database String user = "test"; String

  • J2EE technology JDBC connection formulation of various databases (for beginners) 2009-09-09

    Following is the JDBC connection of the wording of various databases, dedicated to Java for beginners, to some suggestions, I remember driving into the corresponding jar Oh package. 1, Oracle8/8i/9i database (thin model) Class.forName ( "oracle.jdbc.

  • SQL SERVER 2008 using JDBC connection method 2010-09-30

    JDBC connection with SQL SERVER 2008, many people are asking, I also tested several times and found that under the previous method of connection will appear a little problem. The reason is that, SQL SERVER 2008 using a dynamic port mechanism, accordi

  • Various databases using JDBC connection method 2011-06-28

    The following lists the various databases that use JDBC connections, it can be used as a guide. 1, Oracle8/8i/9i database (thin model) Class.forName ("oracle.jdbc.driver.OracleDriver"). NewInstance (); String url = "jdbc: oracle: thin: @ lo

  • JDBC connection string to various databases 2010-10-17

    One. Oracle database connection Class.forName(oracle.jdbc.driver.OracleDriver).newInstance(); String [email protected] Server database name ip1521 ; Connection conn=DriverManager.getConnection(url, User name, password ); II. Mssql database connecti

  • JDBC Connection database skills experience highlights 2010-04-02

    Java Database Connectivity (JDBC) by a group of Java programming language with the class and interface. JDBC as a tool / database developers with a standard API, so that they can use pure Java API to write database applications. However, the interfac

  • JDBC connection pool 2010-08-17

    Introduction In recent years, with the Internet / Intranet networking technology and the rapid development and the rapid worldwide spread, the computer Applications from traditional desktop applications to Web applications. Based on B / S (Browser /

  • jdbc connection pool easy package 2009-04-03

    The main methods of implementation are: The use of a container (LinkedList), initialization time set number of connections to generate Connection objects on the container Each subsequent time to obtain connections from the container to obtain, but th

  • Oracle Database JDBC Connection 2010-05-26

    Connection method: 1. MyEclipse import Oracle's JDBC driver package (oracle \ jbdc \ lib \ classes12.jar); 2. Driver: oracle.jdbc.driver.OracleDriver 3. Connect Address: jdbc: oracle: thin: @ localhost: 1521: database name TestJDBC.java: view sourcep

  • JDBC connection is not on the database 2010-08-05

    This evening there was a special issue of depressed, has been tested and hard about the project can not even run because the connection is not on the database, in order to solve this problem after another in a long time, and I am Wohuo, but the probl

  • A utility class for getting JDBC connection with MySQL 2010-08-06

    Most Java developers had an experience to develop database program using JDBC, so am I. Although there are lots of sophisticated frameworks, such as Hibernate, iBatis, JPA, and so force, used to make database programming easier and more professional,

  • mysql JDBC connection pool problem solving in Chinese 2010-10-07

    In a recent project in the use Mysql as database, application server is a resin. However, the connection pool using the resin was found after the Chinese data is saved to the database garbled, not display correctly. I suppose the reason is not suppor

  • JDK (Java) and the connection method SQLserver 2010-10-27

    SQLserver JDK and the connection method: Method One: Using the JDBC Driver and SQLserver database connection; Method Two: JDBC windows platform by using the ODBC (Data Source) and SQLserver database connection. Experimental environment: Operating Sys

  • JDBC connection Access database insert failed Memo type field 2010-11-30

    In the Access database using JDBC connection, Memo type field into the failure, error: ODBC Microsoft Access Driver] invalid precision value. Can be solved by trying the following. Solution: Method 1. The memo into the last field. Method 2. To ensure

  • Mainstream database JDBC connection 2011-07-13

    Java Database Connectivity (JDBC) by a group of Java programming language classes and interfaces. JDBC for tool / database developers with a standard API, so that they can use pure Java API to write database applications. However, each developer's in

  • Oracle RAC jdbc connection 2011-07-19

    jdbc connection oracle connection string is as follows: String url="jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = host2)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = host1)(PORT = 1521)) (LOAD_BALANCE = yes)(FAILOVER = ON) (

  • means the list of database jdbc connection 2011-01-24

    means the list of database jdbc connection The following lists the various databases that use JDBC connections, it can be used as a guide. 1, Oracle8/8i/9i database (thin model) Class.forName ("oracle.jdbc.driver.OracleDriver"). NewInstance ();

  • (R) JDBC connection must be closed 2011-09-27

    JDBC resources in order to ensure errors are not abnormal or unusual circumstances to be shut down, we should turn off after finished using JDBC resources and free them. JDBC connection JDBC connection pool provides a definition and a limited number

  • jdbc driver 4 and the common types of jdbc connection string 2009-11-19

    1: jdbc driver 4 types Type1: through the use of JDBC-odbc bridge to connect oracle, poor portability Type2: oracle oci: relatively poor portability, it is necessary to depend on the oracle of the oci (client) installation But can be more efficient.

  • Open the Windows 2003 Remote Desktop Connection method 2010-04-22

    Open the Windows 2003 Remote Desktop Connection method (if the set is already a step in the results, you can skip) 1, HKLM \ SYSTEM \ CurrentControlSet \ Control \ Terminal Server \ fDenyTSConnections set its value to 0 2, open the group policy (run