Sha256: f3d87407f402f2b262cb3ce2b175452f0b85472f5447cde19f20e10ebed2a72a
Contents?: true
Size: 1.26 KB
Versions: 12
Compression:
Stored size: 1.26 KB
Contents
import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; public class PgTester { public static void main(String[] args) { Integer startValue = 0; try{ startValue = Integer.parseInt(args[0]); } catch (Exception e){ System.out.println("Please provide a valid number as the first argument to the program"); System.exit(-1); } Connection conn=null; try { Class.forName ("org.postgresql.Driver"); conn = DriverManager.getConnection("jdbc:postgresql://localhost:11002/test"); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } try { //conn.setAutoCommit(false); PreparedStatement query = conn.prepareStatement("INSERT INTO public.sequencetester (recordno) VALUES (?)"); int max = startValue + 10; for(int cv = startValue; cv <= max; cv++){ query.setInt(1, cv); query.execute(); //System.out.println("interted "+cv); } query.close(); //conn.commit(); conn.close(); System.out.println("Done"); } catch (SQLException e) { e.printStackTrace(); } } }
Version data entries
12 entries across 12 versions & 1 rubygems