| From: | Aydın Toprak <aydin(dot)toprak(at)intengo(dot)com> | 
|---|---|
| To: | pgsql-jdbc(at)postgresql(dot)org | 
| Subject: | simple insert operation | 
| Date: | 2005-09-08 07:58:53 | 
| Message-ID: | 431FEF3D.6050906@intengo.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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..
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Csaba Nagy | 2005-09-08 08:17:26 | Re: simple insert operation | 
| Previous Message | Angelo Neuschitzer | 2005-09-07 16:52:51 | BUG #1864: Strange behavoir of batches |