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

分类:Database 2010-07-01 来源:CodeWeblog.com 人气:197

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: @ 10.20.15.207:1521: 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 = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; / / 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 ();

)

)

分享到:
blog comments powered by Disqus

相关文章

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.687 (s). 12 q(s)