Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package JDBC;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.Statement;
- public class Insert_into
- {
- public static void main(String args[])
- {
- Connection c = null;
- Statement stmt = null;
- try
- {
- Class.forName("org.postgresql.Driver");
- c = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres", "postgres",
- "1234");
- System.out.println("Database open ok");
- stmt = c.createStatement();
- String sql = "INSERT INTO \"SEP\".members " + "VALUES (001, 'Premium', 'John Parker', 'Male', Birthdate, 'johnparker10@gmail.com', 8700, 'Horsens', 'VIA 12', 22668899, 1) ;";
- stmt.executeUpdate(sql);
- // String sql1 = "INSERT INTO \"SEP\".membershipType (MembershipType, validity, PaymentMethod, StartDate, EndDate, MembershipCost) VALUES "
- // + " (GUI) ";
- // stmt.executeUpdate(sql1);
- //
- // String sql2 = "INSERT INTO \"SEP\".trainer (TrainerID, TrainerName, Program,) VALUES "
- // + " (GUI) ";
- // stmt.executeUpdate(sql2);
- // String sql = "UPDATE \"SuppParts\".staff set saltopay = 12500.00 where staffno = 'KS03';";
- // stmt.executeUpdate(sql);
- stmt.close();
- c.close();
- } catch (Exception e)
- {
- System.err.println(e.getClass().getName() + ": " + e.getMessage());
- System.exit(0);
- }
- System.out.println("Database update ok");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement