Connection strings commonly used for connecting databases

Source: Internet
Author: User
Tags db2 microsoft sql server odbc sql mysql net postgresql sybase
Connection Database | string

Access connection string:
<%
Dim Conndim connstrdb= "Data/data.mdb" Database file location
On Error Resume Next
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (db) Set Conn=server.createobject (" ADODB. CONNECTION ") If Err Thenerr.clearelseconn.open connstrend if
%>
SQL connection string:
<%
Response.buffer=true
On Error Resume Next
Name=request.cookies ("name")
Connstring= "Driver={sql server};server=.; Database=ebweb2005;uid=sa;pwd= "
Set Nn=server.createobject ("Adodb.connection")
Set Mm=server.createobject ("Adodb.recordset")
Nn.open connstring
%>

Connection string for Java connection Common database

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);
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);



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: [email protected] 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.