Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String args[]){
- try{
- //step1 load the driver class
- Class.forName("oracle.jdbc.driver.OracleDriver");
- //step2 create the connection object
- Connection con=DriverManager.getConnection(
- url,username,password);
- System.out.println("Connection Done");
- //step3 create the statement object
- Statement stmt=con.createStatement();
- Date date = new Date ();
- long time = date.getTime();
- Timestamp ts = new Timestamp(time);
- //STEP 4: Execute a query
- System.out.println("Inserting records into the table...");
- int temp=123;
- String sql="INSERT INTO TEST (INSERTED_DATE,CTID)" +"Values ("+ts+","+temp+");";
- PreparedStatement statement
- = con.prepareStatement(sql);
- System.out.println("Inserted records into the table...");
- statement.executeUpdate();
- //step5 close the connection object
- con.close();
- System.out.println("Goodbye!");
- }catch(Exception e){
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement