Java code to connect various databases

2010-05-03  来源:本站原创  分类:Java  人气:376 

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="test";
Connection conn= DriverManager.getConnection(url,user,password);

2, 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 As the database name
Connection conn= DriverManager.getConnection(url);

3, Sql Server7.0/2000 Database

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb";
//mydb For 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 As your database name
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 As the database name
Connection conn= DriverManager.getConnection(url);

6, DB2 database

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

7, PostgreSQL Database

Class.forName("org.postgresql.Driver").newInstance();
String url ="jdbc:postgresql://localhost/myDB"
//myDB As the database name
String user="myuser";
String password="mypassword";
Connection conn= DriverManager.getConnection(url,user,password);
相关文章
  • 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

  • jdbc connect various databases 2010-04-05

    jdbc connect various databases 1. MySQL (http://www.mysql.com) mm.mysql-2.0.2-bin.jar Class.forName ("org.gjt.mm.mysql.Driver"); cn = DriverManager.getConnection ("jdbc: mysql: / / MyDbComputerNameOrIP: 3306/myDatabaseName", sUsr, sPwd

  • Flex and Java integration to connect the database instance 2010-04-15

    Flex and Java integration to connect the database instance of the effect of photo: Development Tools: eclipse + flex Database: SQL SERVER 2005 Firstly, the database: Database: companyDB Data Table: company USE [companyDB] GO /****** Object: Table [db

  • java way to connect SQL 2005 2010-05-15

    java way to connect SQL 2005: (2008-04-23 00:48:02) reproduced Tags: it Category: JAVA Learning 1. To the Microsoft website to download and unzip jdbc 2005, access to documents sqljdbc.jar 2. Copy files to the jdk directory sqljdbc.jar \ jdk1.5 \ jre

  • ttserver install + ttserver start and stop script (double standby) + java code 2010-09-02

    by: alex 1, download tokyocabinet-1.4.46.tar.gz Download tokyotyrant-1.1.41.tar.gz To select the local connection can download tokyocabinet-java-1.22.tar.gz Detailed installation documentation http://www.162cm.com/p/tokyotyrant.html 2, extracted into

  • With the JAVA code to access a URL address is available how to write? 2010-10-26

    With the JAVA code to access a URL address is available how to write? First of all, tell us about get by: String mainDomain = agentFacade.getVirtualHostService().getMainDomainName(domain); String webServer =this.getVzzjzManageService().getVZZJZWebSit

  • ttserver installation + ttserver start-stop script (double standby) + java code 2010-09-02

    by: alex 1, download tokyocabinet-1.4.46.tar.gz Download tokyotyrant-1.1.41.tar.gz You can choose to download local connection tokyocabinet-java-1.22.tar.gz Detailed installation documentation http://www.162cm.com/p/tokyotyrant.html 2, unzip into the

  • Java code examples to explain the various methods of connecting to an Oracle database 2010-10-26

    java and oracle of the interface: JAVA can be run in the database is ORACLE8i the most exciting new features. ORACLE8i you create a database using an application, you can use and JAVA-related new features, easy to program to the INTERNET or an INTRAN

  • Agile Development of Java code to write high-quality 2009-12-24

    Agile development concept has been popular for a very long time, the development of agile development iteration stage, we can through the five steps to effectively improve the quality of the entire project code. Java project development process, due

  • Java language coding standards (Java Code Conventions 2009-01-05

    At the beginning of Notes ") http://www.huihoo.org/code/java_code_conventions.html - Package and the introduction of statements (see "package and the introduction of statements") - Class and interface declarations (see "classes and int

  • [Change] agile development of high-quality Java code to write 2009-09-29

    Agile development concept has been popular for a very long time, the development of agile development iteration stage, we can through the five steps to effectively improve the quality of the entire project code. Java project development process, due

  • The use of java code to send a HTTP Post request 2010-03-21

    The use of java code to send a HTTP Post request code is as follows, without too much explanation of it: package imscportal.transform.http.channel.impl; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStream; imp

  • Java code analysis tool for the problem of effective java thread dump 2010-03-26

    Analysis of Java code to the most effective tool is still java thread dump, the support staff is particularly important because: - Any operating system platform can be used. - In most cases, you can use in a production environment. - Provide the tool

  • Write java code LoadRunner 2010-02-05

    've Done some research this afternoon, completed the Java code in loadRunner in operation. Steps are as follows: 1, use LoadRunner's VU Generator New Java VUser. 2, write Java code in the actions, attention, try to work the system needs to initialize

  • Eclipse developers can use LoadRunner to run the Java code 2010-02-05

    Java developers using the LoadRunner testing, and if we can directly use the Java programs written test, then, will feel very comfortable. The native LoadRunner Java language itself, the editor is very unfriendly to use, if we can edit the Java code

  • Agile Java code to write high-quality 2010-03-10

    Source: IBM dW / Wang Yongkui | De idea of agile development has been popular for a long time in Agile Development Kaifa iteration stage, we can through the five steps to effectively improve the entire project code quality. Java project development p

  • Java code using JDEE as a reader 2010-04-06

    Emacs is absolutely great software, some shameless villain than the secular far to great, but some of its design to the letter and still affect a lot of development tools. JDEE is a great software, I JDEE mailing list, get feedback very very happy: W

  • 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

  • Regular expressions used in Java code 2010-04-21

    Regular expressions used in Java code: Input feature the winning numbers, winning numbers for input validation: /** * Use regular validation Lotto numbers ( Parametric ) * * @param pattern * Regular expressions * @param content * Content * @author hl

  • java Code Generation 2010-05-01

    1. Generated verification code: using technology jsp, servlet 2. Generated verification code in the servlet: package servlet; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.I