Records - Note-mysql-Oracle-sqlserver-connect to the database

package connectionDriver;

import java.sql.Connection;
import java.sql.DriverManager;
public class connectionDatabases (

/ / Private final String oracleDriverName = "oracle.jdbc.driver.OracleDriver"; / / oracle driver name
/ / Private final String oracleUrlToConnect = "jdbc: oracle: thin: @ orcl"; / / oracle connection string
private final String oracleDriverName = "com.mysql.jdbc.Driver"; / / mysql driver name
private final String oracleUrlToConnect = "jdbc: mysql: / / localhost: 3306/test"; / / mysql connection string
/ / Private final String oracleDriverName = ""; / / sqlserver driver name
/ / Private final String oracleUrlToConnect = "jdbc: microsoft: sqlserver: / / localhost: 1433; DatabaseName = students"; / / sqlserver connection string
private Connection Conn = null;
public Connection getConnection () (
try (
Class.forName (oracleDriverName);
this.Conn = DriverManager.getConnection (oracleUrlToConnect, "root", "root ");//" biztest", "caijbiz" / "biz", "bizchina1" / "jpzbiz", "bizjpz"

System.out.println ("-------- database connection successful ---------");
) Catch (Exception ex) (
ex.printStackTrace ();
System.out.println ("-------- Database connection failed ---------");
return this.Conn;
public static void main (String [] args) (
connectionDatabases a = new connectionDatabases ();
a.getConnection ();



分类:Database 时间:2010-07-01 人气:198
blog comments powered by Disqus


  • JDBC connection to access the MySQL database 2011-04-01

    package com.lian.jdbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class ConnectMySQL { /* * Database connection tools */ private static final String Driver = "com.mysql.jdbc.Driver"; private s

  • tomcat6 database connection pool (DBCP) configuration (mysql for example) 2011-05-03

    Because JNDI configuration in tomcat5.0 and tomcat5.5.x been modified, so the previous tomcat6 the JNDI configuration is somewhat different, this article only describes the configuration database connection pool tomcat6 below. tomcat support JDBC2.0

  • Tomcat connection pool configured in MySql 2010-06-06

    As directly edit the server.xml configuration connection pool is prone to error, I guess tomcat version of the problem, not a version may have slightly different configuration, so I recommend using the data source in http://localhost/admin/ configura

  • oracle of rownum, sql server in the top function, mysql in the limit 2010-04-26

    oracle of rownum, sql server in the top function, mysql in the limit Sql server: / / The first 5 rows select top 5 * from table / / Check the first 11 rows to 20 rows select top 10 * from [table name] where [primary key] not in (select top 10 [primar

  • mysql错误:No suitable driver found for jdbc:mysql... 2013-09-10

    今天从网上下载了一段别人分享的代码,按一般步骤导入到myeclipse里,导入mysql.jar包,结果报No suitable driver found for jdbc:mysql://localhost:3306/library错误 开始还以为是mysql包的版本不对,结果试了好几个都没有,仔细的观察源代码,url和密码都没有写错,包导入没错,百度了半天,将jar加入到某某路径里去,路径是否写错,或者是将localhost改为127.0.0.1.....全没有用 当时感觉相当的不爽 ...

  • JDBC connection commonly written (including MySQL.Oracle.Sybase.SQLServer.DB2) 2011-07-05

    1. MySQL Class.forName ("com.mysql.jdbc.Driver"); cn = DriverManager.getConnection ("jdbc: mysql: / / MyDbComputerNameOrIP: 3306/myDatabaseName", sUsr, sPwd); 2. PostgreSQL Class.forName ("org.postgresql.Driver"); cn = Driver

  • to the host's TCP / IP connection failed. 2010-03-28

    Written test when doing hibernat class when an error occurs. to the host's TCP / IP connection failed. Connection refused: connect After much search discovered the problem wh

  • mysql connection string (to) 2010-12-07

    mysql JDBC driver used to have two, one is gjt (Giant Java Tree) organizations mysql driver, the JDBC Driver Name (JAVA class name) is: See website: Another is provided by the official mysql JDBC Driver, th

  • java.sql.SQLException: [Microsoft] [SQLServer 2000 Driver for JDBC] Can't start a 2011-05-09

    Error conditions: java.sql.SQLException: [Microsoft] [SQLServer 2000 Driver for JDBC] Can't start a cloned connection while in manual transaction mode. Error reason: (1) When you are in a SQL SERVER the JDBC connection to perform the operation multip

  • java.sql.SQLException: [Microsoft] [SQLServer 2000 Driver for JDBC] Error establis 2010-05-02

    jdbc connection sql server2000 exception: java.sql.SQLException: [Microsoft] [SQLServer 2000 Driver for JDBC] Error establishing socket. Reason: As the development environment is Win 2003 Server / xp, it needs SQL 2000 patch, or under the 2k3, SQL de

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 闽ICP备15018612号

processed in 0.252 (s). 10 q(s)