Common database JDBC driver download address and URL Usage Summary

Source: Internet
Author: User
Tags db2 microsoft sql server odbc postgresql sybase
1.Mysql
Download Address: http://www.mysql.com/products/connector/j/
Instructions for use:
Class.forName ("Org.gjt.mm.mysql.Driver");
cn = Drivermanager.getconnection ("Jdbc:mysql://mydbcomputernameorip:3306/mydatabasename", SUSR, SPWD);
2.Oracle Download Address:Http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html
Instructions for use:
Class.forName ("Oracle.jdbc.driver.OracleDriver");
cn = Drivermanager.getconnection ("Jdbc:oracle:thin: @MyDbComputerNameOrIP: 1521:orcl", SUSR, spwd); 3.Microsoft SQL Server Download Address:http://www.microsoft.com
Instructions for use:
Class.forName ("Com.microsoft.jdbc.sqlserver.SQLServerDriver");
cn = Drivermanager.getconnection ("Jdbc:microsoft:sqlserver://mydbcomputernameorip:1433;databasename=master", SUSR , spwd); 4.SyBase Download Address:http://jtds.sourceforge.net/
Instructions for use:
Class.forName ("Com.sybase.jdbc2.jdbc.SybDriver");
cn = Drivermanager.getconnection ("jdbc:sybase:tds:mydbcomputernameorip:2638", Susr, spwd); 5.Microsoft SQL Server and SyBase by Jtds Download Address:Http://jtds.sourceforge.net
Instructions for use:
Class.forName ("Net.sourceforge.jtds.jdbc.Driver");
cn = Drivermanager.getconnection ("Jdbc:jtds:sqlserver://mydbcomputernameorip:1433/master", SUSR, SPWD); 6.PostgreSQL Download Address:http://www.de.postgresql.org
Instructions for use:
Class.forName ("Org.postgresql.Driver");
cn = Drivermanager.getconnection ("Jdbc:postgresql://mydbcomputernameorip/mydatabasename", SUSR, SPWD); 7.SAP DB Download Address:Http://www.sapdb.org/sap_db_jdbc.htm

Instructions for use:
Class.forName ("Com.sap.dbtech.jdbc.DriverSapDB");
Java.sql.Connection Connection = java.sql.DriverManager.getConnection ("jdbc:sapdb://" + host + "/" + Database_name,user _name, password);
8.ODBC
Instructions for use:
Class.forName ("Sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn = Drivermanager.getconnection ("JDBC:ODBC:" + sdsn, SUSR, spwd);
9.db2
Instructions for use:
Class.forName ("Com.ibm.db2.jdbc.net.DB2Driver");
String url= "Jdbc:db2://192.9.200.108:6789/sample"
cn = Drivermanager.getconnection (URL, susr, spwd);

10.access
Download Address: http://rmijdbc.objectweb.org/Access/access.html
Instructions for use:
Because access is not run as a service, the URL method does not apply to him. Access can be found through ODBC, or by the form of a server mapping path. mdb files



The use process of the JDBC API:
(1) Registering and loading the JDBC driver;
Two ways:
Class.forName (String drivername);
Drivermanager.registerdriver (Driver Driver)
(2) establishing 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.

The

(5) Retrieves the results of the query.
    resultset methods;
    Boolean next (): False when no rows are returned;
    String getString (String columnName): Returns the value corresponding to the column name.

Some of the basic things I've sorted out in JDBC, due to software and drive updates quickly, more detailed information, you can go to http://java.sun.com/products/jdbc/reference/ View on industrysupport/index.html.

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.