X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B9956DB5F5 for ; Wed, 23 Nov 2005 07:10:39 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47267-09 for ; Wed, 23 Nov 2005 11:10:40 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mra04.ch.as12513.net (mra04.ch.as12513.net [82.153.252.44]) by svr1.postgresql.org (Postfix) with ESMTP id AE312D8FD5 for ; Wed, 23 Nov 2005 07:10:35 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by mra04.ch.as12513.net (Postfix) with ESMTP id 0AF68C0835; Wed, 23 Nov 2005 11:10:38 +0000 (GMT) Received: from mra04.ch.as12513.net ([127.0.0.1]) by localhost (mra04.ch.as12513.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 19733-01-13; Wed, 23 Nov 2005 11:10:37 +0000 (GMT) Received: from [10.0.0.151] (unknown [81.5.146.249]) by mra04.ch.as12513.net (Postfix) with ESMTP id 63BB7C0AC0; Wed, 23 Nov 2005 11:10:37 +0000 (GMT) Message-ID: <43844E24.3030700@rkcomputing.co.uk> Date: Wed, 23 Nov 2005 11:10:28 +0000 From: Rob Kirkbride User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: smitha CC: pgsql-jdbc@postgresql.org Subject: Re: Switching user within connection. References: <20051123101605.72289.qmail@web60221.mail.yahoo.com> In-Reply-To: <20051123101605.72289.qmail@web60221.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by Eclipse VIRUSshield at eclipse.net.uk X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/165 X-Sequence-Number: 14263 smitha wrote: > Hi Rob !! > > Just now I got ur Query. I will check it. I have doubt. If > You know the answer for this Please reply to me. I am breaking my head > to solve this. > > 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) > { > //Ge t 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"); > > } > } > > * (Correct top post - also please don't email off list) I use the following syntax : create user 'username' encrypted password 'password' It works ok for me providing I don't try and use a prepared statement - it doesn't seem to translate the $1 correctly in the username. Rob