simple insert operation - Mailing list pgsql-jdbc

From Aydın Toprak
Subject simple insert operation
Date
Msg-id 431FEF3D.6050906@intengo.com
Whole thread Raw
Responses Re: simple insert operation  (Csaba Nagy <nagy@ecircle-ag.com>)
Re: simple insert operation  (Roland Walter <rwa@mosaic-ag.com>)
Re: simple insert operation  (Diego Gil <diego@adminsa.com>)
List pgsql-jdbc
Hii guys,

I am very newbie about postgresql and I am making practice,
however I couldnt been able to insert a simple item to my DB via jdbc...


here is my code  for insertion...

        Class.forName("org.postgresql.Driver");
        String connectionStr = "jdbc:postgresql://localhost:5432/XXXX";
        Connection connection =
java.sql.DriverManager.getConnection(connectionStr, "XXXX", "XXXX");
        String sqlQuery = "INSERT INTO passTable (idCol , pass) VALUES
(3, 5)";
        PreparedStatement query = connection.prepareStatement(sqlQuery);
        query.executeUpdate();
        connection.close();

but I cant compile it

the errors

-------------------------------------------------------------------------------------------
form.java:26: unreported exception java.lang.ClassNotFoundException;
must be cau
ght or declared to be thrown
                Class.forName("org.postgresql.Driver");
                             ^
form.java:28: unreported exception java.sql.SQLException; must be caught
or decl
ared to be thrown
                Connection connection =
java.sql.DriverManager.getConnection(con
nectionStr, "XXXX", "XXXX");

^
form.java:30: unreported exception java.sql.SQLException; must be caught
or decl
ared to be thrown
                PreparedStatement query =
connection.prepareStatement(sqlQuery);

                                                                     ^
form.java:31: unreported exception java.sql.SQLException; must be caught
or decl
ared to be thrown
                query.executeUpdate();
                                   ^
form.java:32: unreported exception java.sql.SQLException; must be caught
or decl
ared to be thrown
                connection.close();
                                ^
5 errors
-------------------------------------------------------------------------------------------

what is the problem I am stuck with it..





pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: Change in parameters' order in prepared statement??
Next
From: Csaba Nagy
Date:
Subject: Re: simple insert operation