Database using JDBC code to connect different

2011-09-10  来源:本站原创  分类:Database  人气:126 

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

Class.forName ("oracle.jdbc.driver.OracleDriver"). NewInstance ();
String url = "jdbc: oracle: thin: @ localhost: 1521: orcl"; / / orcl is the database SID
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 name for your database
String user = "admin";
String password = "";
Connection conn = DriverManager.getConnection (url, user, password);

3, SQLServer2005/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 & useUnicode = 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);

8, Access database used in conjunction with the ODBC direct

Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc: odbc: Driver = {MicroSoft Access Driver (*. mdb)}; DBQ =" + application.getRealPath ("/ Data / ReportDemo.mdb");
Connection conn = DriverManager.getConnection (url ,"","");
Statement stmtNew = conn.createStatement ();

相关文章
  • Database using JDBC code to connect different 2011-09-10

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

  • php mysql database connection code to connect database operation code _php 2010-04-06

    <?php mysql_connect("localhost","root","123456") // Fill out the MySQL username and password or die("Could not connect to MySQL server!"); mysql_select_db("phpcms") // The database name or die("Cou

  • Common database, all JDBC connections Raiders Raiders written all connect to the database used DriverManager.getConnection 2010-07-15

    Common database, all JDBC connections Raiders Raiders written all connect to the database used DriverManager.getConnection Oracle8/8i/9i database (thin model) Class.forName ("oracle.jdbc.driver.OracleDriver"). NewInstance (); String url = "

  • JSP review notes - Chapter 10 of connecting to the database using JDBC Introduction and basic 2010-10-26

    The maximum dynamic web features -> can work with databases JSP is the dynamic web programs -> JDBC to operate the database Java JDBC connecting to the database itself is a standard among database can be found on the database processing by the datab

  • Query the database using JDBC 2010-04-21

    JDBC API's core components: 1.DriverManager categories: term tracking of available JDBC driver and create a database connection. 2.Connection interface: access database information, generate a database statement, and manage the database transaction.

  • Oracle database via JDBC connection Ten Tips [change] 2010-07-14

    Java Database Connectivity (JDBC) API is a set that allows Java programmers to access the database interface, the interface is not identical to each developer. The use of Oracle's JDBC years, I accumulated a lot of skills, these skills will enable us

  • Oracle database via JDBC connection Ten Tips 2010-08-18

    Java Database Connectivity (JDBC) API is a set that allows Java programmers to access the database interface, the interface is not identical to each developer. In use for many years after the Oracle Corporation's JDBC, I gained many skills, these ski

  • Connect to the database with jdbc.properties 2010-06-02

    Connect to the database in this way is safer. DBSource.java package jdbc; import java.sql.Connection; import java.sql.SQLException; public interface DBSource { public Connection getConnection()throws SQLException; public void closeConnection(Connecti

  • jsp code to connect Mysql database and display 2010-10-21

    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*"%> <html> <body> The following is from the MySQL database data read :</hr> <% Class.forName("com.mysql.jdbc.D

  • JDBC Java database connectivity test code SQLServer2000 2011-09-07

    import java.sql .*; public class JDBC { public static void main (String [] args) { String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; String dbURL = "jdbc: microsoft: sqlserver: / / localhost: 1433; databasename = li";

  • derby embedded database java jdbc 2011-08-25

    Using the embedded database, the general steps are as follows: 1: Download the derby 2: Configure derby_home 3: Setting classpath One thing to note is: the use ij to connect, create the database, the database is affected by running the command in the

  • Summary database and JDBC 2010-10-20

    Articles in red font for the result of running mysql, mysql in black font for the technical point of 1. See what the library database, the expression: show databases; mysql> show databases ->; +--------------------+ | Database | +-------------------

  • JDBC driver to connect SQL server 2005 2011-02-23

    Yesterday, a driver under Microsoft SQL Server JDBC Driver 3.0 is sqljdbc_3.0 sqljdbc4.jar to copy the lib under the under the Annex, as sqljdbc_3.0, the configuration in the applicationContext.xml in the C3P0 connection pool data source <beans> <

  • MySql remote connect to the database is not allowed to connect to this MySQL server 2011-07-06

    1. Change table method. Your account may be allowed from a remote landing, only localhost. This time as long as that computer on localhost, mysql login after change "mysql" database in the "user" table of "host" entry from &q

  • Derby database via JDBC operations (two) 2011-08-12

    Derby Version: db-derby-10.8.1.2 Catalog Analysis: 1) bin directory, the script contains a number of tools and equipment for the environment script; 2) demo directory contains some example programs; 3) docs directory contains the Derby documentation;

  • Operation of the database for JDBC public class 2010-04-29

    Haha, and then issued a public database for the JDBC operation class, that is what I wrote a long time ago, in which RWProperties class in my "Java-based" category has a "Properties properties for the preparation of documents to read and wr

  • Java code to connect various databases 2010-05-03

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

  • PowerDesigner MySql database using JDBC connection configuration: 2010-03-06

    1. Installation: PowerDesigner version is 12.5, mysql 5.0 2. Install java 3. Configure the system environment java_home, classpath, path 4. If you are using jdbc to connect mysql, please mysql.jar file path and going with the classpath.

  • HSQLDB database and JDBC connection installation starts 2010-05-22

    HSQLDB is the development of a lightweight pure Java open-source relational database system. Because HSQLDB lightweight (small footprint), easy to use, support for memory operation mode, etc., HSQLDB is widely used development environment and some sm

  • SqlServer additional database error, error code 5123 2010-07-20

    In the Attach a previous database (not in SqlServer initial installation directory), when not always add on, always appears the error code 5123, as shown: Beginning that is not compatible with the original database SqlServer2008 caused because the da