标签:
package cn.zno.jdbc.jdbc; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class Main { public static void main(String[] args) { String driver = "oracle.jdbc.OracleDriver";// 驱动类全路径名 String url = "jdbc:oracle:thin:@//myhost:1521/myservicename";// url String username = "scott";// 用户名 String password = "tiger";// 密码 // 第一步:加载驱动 try { Class.forName(driver); } catch (ClassNotFoundException e) { e.printStackTrace(); } // 第二步:建立连接 try { Connection con = DriverManager.getConnection(url, username, password); } catch (SQLException e) { e.printStackTrace(); } } }
标签:
原文地址:http://www.cnblogs.com/zno2/p/4564257.html