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

sponsored links
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 ();


  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Records - Note-mysql-Oracle-sqlserver-connect to the database

  • hibernate to use the principle of

    The use of hibernate, implementation of data persistence. Has the following several processes. One configuration database connection information. Hibernate.config 2 configuration mapping. 3 use: the use of the process are the following steps: 3.1: Ge ...

  • hibernate generic generic DAO

    package org.lzpeng.dao; import; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

  • Servlet brief introduction

    Servlet brief introduction: Servlet is a small application server Are used to complete the B / S architecture, the client requests the response to treatment Platform independence, performance, able to run thread Servlet API for Servlet provides the s ...

  • can not be represented as java.sql.Timestamp

    Development of procedures for the use of hibernate when, some time there is no need to fill in the fields, but after the hibernate query time reported "Java.sql.SQLException: Value'0000-00-00 'can not be represented as java.sql.Timestamp ...

  • First Hibernate Example

    Curd a simple example. Source does not contain the dependent libraries, or playing too much of the package. PO object Note: One must have the default constructor 2 non-final modified. Otherwise useless lazy loading. UserDAOImpl category code, and other co

  • spring struts2.0 hibernate environmental structures .. despair carried out more than one hour only with good. Look here. . Note added myeclipse support spring when necessary add the commons-dbcp database connection pool package. And to add hibernate support. . Finally add struts2 support. . Oh the lazy point. . . fu

  • Hibernate annotation using notebook

    These are the basic common @Entity --Declared an entity bean @Table(name="promotion_info") --For the entity bean mapping for the specified table (Table name ="promotion_info) @Id --Declare that the identifying attribute of the entity bean @GeneratedValue

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

blog comments powered by Disqus
Recent Entries
Tag Cloud
Random Entries