1, follow Oracle
2, CREATE DATABASE footsteps
DROP TABLE person; DROP SEQUENCE myseq ; //Set the self-increment sequence. CREATE SEQUENCE myseq; The CREATE TABLE person ( ID INT PRIMARY KEY is not null, name VARCHAR () is not null, Age INT, birthday DATE);
3, then configure the driver.
4, execute:
Get program: Dbdriver = "Oracle.jdbc.driver.OracleDriver",
JDBC Address: Dburl = "Jdbc:oracle:thin: @localhost: 1521:sys"
Packageclass set;Importjava.sql.Connection;ImportJava.sql.DriverManager;Importjava.sql.SQLException;Importjava.sql.PreparedStatement; Public classjdbcoracle{//define a MySQL database driver Public Static FinalString dbdriver = "Oracle.jdbc.driver.OracleDriver" ; //Define the connection address of the MySQL database Public Static FinalString Dburl = "Jdbc:oracle:thin: @localhost: 1521:sys" ; //connection user name for MySQL database Public Static FinalString DBUSER = "Scott" ; //connection password for MySQL database Public Static FinalString Dbpass = "Tiger" ; Public Static voidMain (String args[])throwsexception{//all exceptions ThrownConnection conn =NULL;//Database ConnectionClass.forName (Dbdriver);//Load Driverconn =drivermanager.getconnection (Dburl,dbuser,dbpass); PreparedStatement pstmt=NULL ; String SQL= "INSERT into person (id,name,age,birthday) VALUES (Myseq.nextval,?,?,?)";//Manually set the primary Key's self-increment pstmt=conn.preparestatement (SQL); Pstmt.setstring (1, "Xiao Hua") ; Pstmt.setint (2,30) ; Pstmt.setdate (3,NewJava.sql.Date (Newjava.util.Date (). GetTime ())) ; Pstmt.executeupdate (); //Perform an update operationPstmt.close (); Conn.close (); //Database Shutdown }};
When using Oracle connectivity, Oracle will automatically configure the new JRE environment as soon as it is used, and to make its own JRE work, you must remove these configurations from Oracle,
JDBC for Oracle database operations.