Java通过JDBC连接Oracle数据库

Java通过JDBC连接Oracle数据库

1. 下载Oracle连接驱动

https://mvnrepository.com/artifact/com.oracle/ojdbc6/12.1.0.1-atlassian-hosted

2.Java代码实现连接

         String username = "用户名";
         String password = "密码";
         String driver = "oracle.jdbc.driver.OracleDriver";
         String ip="数据库IP";
         String port="端口号";
         String database="数据库名称";
         String url = "jdbc:oracle:thin:@"+ip+":"+port+":"+database;
         Class.forName(driver);
         Connection connection=DriverManager.getConnection(url, username, password);
         System.out.println(connection);

你可能感兴趣的:(数据库)