pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Reg : Exception ( Postgresql with Java -JDBC)
2+ messages / 2 participants
[nested] [flat]

* Reg : Exception ( Postgresql with Java -JDBC)
@ 2005-11-23 08:27  smitha <smitha_alice_c@yahoo.com>
  0 siblings, 1 reply; 2+ messages in thread

From: smitha @ 2005-11-23 08:27 UTC (permalink / raw)
  To: pgsql-jdbc

 This is my Java Program.  I get connected with the Postgresql Database and the query get executed and it affects in the Database.....A new user is created in the Database.. But i am getting the Exception "No result were returned by the query"  what could be the reason.....Plz tell me
 
 
 // .java - example connection to a Postgresql (Database)
 
 import java.io.*;
 import java.sql.*;
 
 public class connect
 {
     public static String villageName = null;
     public static final boolean DEBUG = false;
 
     public static void main (String[] args)
     {
         //Get a Connection to Postgres
         try
         {
             Class.forName("org.postgresql.Driver");
         }
         catch (ClassNotFoundException e)
         {
             System.err.println( "Driver not found: " + e + "\n" + e.getMessage() );
         }
         try
         {
             String url="jdbc:postgresql://10.163.2.95:5432/collabland";
             Connection con=DriverManager.getConnection(url,"postgres","postgres");
             Statement st=con.createStatement();
  
     String logName = "kala";
     String passwd = "kala";
    
     String  query1 = "CREATE user " + logName + " with password '" + passwd + "' createuser";
             ResultSet rs= st.executeQuery(query1);
        System.out.println(query1);
        System.out.println("user created");
         }
         catch (SQLException sqlex)
             {
                 if (DEBUG) sqlex.printStackTrace();
                System.out.println(sqlex.getMessage());
              //  return false;
             }
                System.out.println("after catch block");
 
            }
 }

		
---------------------------------
 Yahoo! FareChase - Search multiple travel sites in one click.  

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Reg : Exception ( Postgresql with Java -JDBC)
@ 2005-11-23 11:31  Oliver Jowett <oliver@opencloud.com>
  parent: smitha <smitha_alice_c@yahoo.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Oliver Jowett @ 2005-11-23 11:31 UTC (permalink / raw)
  To: smitha <smitha_alice_c@yahoo.com>; +Cc: pgsql-jdbc

smitha wrote:

>   &nb sp; String  query1 = "CREATE user " + logName + " with password '" 
> + passwd + "' createuser";
>             ResultSet rs= st.executeQuery(query1);

CREATE USER does not return a resultset, so you should use 
executeUpdate() or execute(), not executeQuery(). See the JDBC javadoc.

-O



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-11-23 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-11-23 08:27 Reg : Exception ( Postgresql with Java -JDBC) smitha <smitha_alice_c@yahoo.com>
2005-11-23 11:31 ` Oliver Jowett <oliver@opencloud.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox