package com.shangsheng;
import java.sql.*;
public class UserOracle {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
final String username="scott";
final String password="root";
final String url="jdbc:oracle:thin:@127.0.0.1:1521:orcl";
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connection = DriverManager.getConnection(url,username,password);
Statement statement = connection.createStatement();
// String sql="select * from usertest ";
// ResultSet resultSet = statement.executeQuery(sql);
// while (resultSet.next()){
// int anInt = resultSet.getInt(1);
// String string = resultSet.getString(2);
// System.out.println("id:"+anInt);
// System.out.println("name:"+string);
// }
//create sequence usertest_key 创建序列
String sql="insert into USERTEST values(usertest_key.nextval,嘻嘻嘻') ";
statement.execute(sql);
statement.close();
}
}
配置:
<dependency>
<groupId>com.hynnet</groupId>
<artifactId>oracle-driver-ojdbc</artifactId>
<version>12.1.0.2</version>
</dependency>