JDBC connectstring

jdbc:oracle:thin:test/[email protected]:1521:xe

jdbc:mysql://192.168.101.128/TEMPDB?user=test&password=test&autoReconnect=true&failOverReadOnly=false&maxReconnects=100

jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test;user=test;password=test

加载驱动

static{
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Class.forName("oracle.jdbc.OracleDriver");
            
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        //Class.forName("net.sourceforge.jtds.jdbc.Driver");  

    } 

引入驱动包

<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>
     <dependency>
     <groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.1.0</version>
 </dependency>

对sqlserver需要手工导入

 <dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version> 

<scope>system</scope>  
    <systemPath>${project.basedir}/lib/sqljdbc4.jar</systemPath>

</dependency>

你可能感兴趣的:(JDBC connectstring)