JDBC's various database driver downloads and connection string URL notation

Source: Internet
Author: User
Tags db2 microsoft sql server odbc postgresql sybase support microsoft



JDBC Driver downloads and connection string URL writing for various databases

JDBC Driver list on Sun's official website:http://java.sun.com/products/jdbc/reference/industrysupport/index.html

Database Description
Mysql http://www.mysql.com/products/connector/j/Shipped. But need to download the latest for MySQL 4.1 or higher.
Oracle Http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html Included.
SQL Server by Jtds http://sourceforge.net/project/showfiles.php?group_id=33291 Included. Support Microsoft SQL Server (6.5, 7, and 2005)
Postgres http://jdbc.postgresql.org/download.html Included 7.3 JDBC 3
SAP DB Http://www.sapdb.org/sap_db_jdbc.htm Included.
SyBase by Jtds Http://jtds.sourceforge.net/Included. Support Sybase (10, 11, 12)


The following content comes from the Internet

1. MySQL (http://www.mysql.com) Mysql-connector-java-2.0.14-bin.jar;
Class.forName ("Org.gjt.mm.mysql.Driver");
cn = Drivermanager.getconnection ("Jdbc:mysql://mydbcomputernameorip:3306/mydatabasename", SUSR, SPWD);
2. PostgreSQL (http://www.de.postgresql.org) Pgjdbc2.jar;
Class.forName ("Org.postgresql.Driver");
cn = Drivermanager.getconnection ("Jdbc:postgresql://mydbcomputernameorip/mydatabasename", SUSR, SPWD);
3. Oracle (http://www.oracle.com/ip/deploy/database/oracle9i/) classes12.zip;
Class.forName ("Oracle.jdbc.driver.OracleDriver");
cn = Drivermanager.getconnection ("Jdbc:oracle:thin: @MyDbComputerNameOrIP: 1521:orcl", SUSR, spwd);
4. Sybase (http://jtds.sourceforge.net) Jconn2.jar;
Class.forName ("Com.sybase.jdbc2.jdbc.SybDriver");
cn = Drivermanager.getconnection ("jdbc:sybase:tds:mydbcomputernameorip:2638", Susr, spwd);
(Default-username/password: "DBA"/"SQL")
5. Microsoft SQL Server (http://jtds.sourceforge.net);
Class.forName ("Net.sourceforge.jtds.jdbc.Driver");
cn = Drivermanager.getconnection ("Jdbc:jtds:sqlserver://mydbcomputernameorip:1433/master", SUSR, SPWD);
6. Microsoft SQL Server (http://www.microsoft.com);
Class.forName ("Com.microsoft.jdbc.sqlserver.SQLServerDriver");
cn = Drivermanager.getconnection ("Jdbc:microsoft:sqlserver://mydbcomputernameorip:1433;databasename=master", SUSR , spwd);
7. ODBC
Class.forName ("Sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn = Drivermanager.getconnection ("JDBC:ODBC:" + sdsn, SUSR, spwd);
8.DB2 class.forname ("Com.ibm.db2.jdbc.net.DB2Driver");
String url= "Jdbc:db2://192.9.200.108:6789/sample"
cn = Drivermanager.getconnection (URL, susr, spwd);
9.access because access is not run as a service, the URL method does not apply to him. Access can be found through ODBC or, in the form of a server mapping path, to. mdb files, see http://rmijdbc.objectweb.org/Access/access.html
How the JDBC API is used
(1) Registering and loading the JDBC driver;
Two ways:
Class.forName (String drivername);
Drivermanager.registerdriver (Driver Driver) (2) establishes a connection with the SQL database;
DriverManager's Getconnection () method:
Connection getconnection (string url): The URL represents the database address string;
Connection getconnection (String url,string user,string pwd)
Connection getconnection (String url,properties info)
(3) sending a SQL query;
Connection's Createstatement () method:
Statement createstatement ();
Statement can execute SQL statements and get the results of SQL queries. (4) Obtain the result set.
Statement Execute SQL statement method:
ResultSet executequery (String sql): Executing a SELECT statement
int executeupdate (String sql): Executes an UPDATE statement, such as Insert,delete,update. (5) Retrieve the results of the query.
The ResultSet method:
Boolean next (): False when no rows are returned;
String getString (String columnName): Returns the value of the column name.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.