[hotjoe.com] HotJoe Java Help Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Visit java.com
Please send email if you are having login problems - see the posts below for more info.
Hotmail and Yahoo! users - please see the Hotmail post or the Yahoo! post for information on lost emails.
Connect to another database or user in JISQL  XML
Forum Index » Jisql
Author Message
shivanigoyal

Newbie

Joined: 07/23/2007 04:18:35
Messages: 2
Location: zxZ
Offline

Hi,

I am new to JISQL.
Can anyone tell me how we can connect to another database or another user.
For example we have done create user A;
Now i want to change the user from current user to A.
How shall I do it.

In PSQL we do it like
\connect ot \c [DBNAME [USERNAME]]
[WWW] [Yahoo!] aim icon [MSN] [ICQ]
stdunbar

Newbie
[Avatar]

Joined: 06/22/2005 14:51:37
Messages: 849
Location: Superior, CO, USA
Offline

There isn't anything like that in Jisql currently. It would require disconnecting and reconnecting to the database. But the real problem is changing databases. That would require a different connection string.

Each JDBC driver vendor puts the database name in slightly different places. Off the top of my head I could change it so that the connection string has some sort of marker in it to include the database name and then add an option to specify the initial database. The cstring argument would look something like:



and if you indicated that you wanted to connect to a different database then $DBNAME would be updated and Jisql would reconnect

Does that sound usable? It's kind of a pain - it requires a non-standard connection string though it wouldn't be difficult to support the standard one also.

Just a thought - let me know what you think about this change.

Thanks for using the forums at hotjoe.com
[WWW] [Yahoo!] [ICQ]
shivanigoyal

Newbie

Joined: 07/23/2007 04:18:35
Messages: 2
Location: zxZ
Offline

Ok. My current requirement is only change of user to check Grant and Revoke.

But when I tried to disconnect and reconnect by specifying the new user in connection string it shows an error.

For example build is my Linux user.
When i tried to connect to database using this user in connection string as :

jdbc:postgresql://localhost:5432:test_db22 -user build -password password -c \;

Then I am able to connect.
But when I create a user through sql command as:

Create user A;

And then try to coonect through user A as:

jdbc:postgresql://localhost:5432:test_db22 -user build -password password -c \;

It shows an error : ERROR: database "A" does not exist ErrorCode: 0

I want to connect to database though user created by database.

Also while trying doing so, I found following things:

1) My user 'Build ' has a password, but i when I did not specify the password, it asked me for password with message: "hit enter for no password".
I hit enter it then too it connected me to database.

2) Also if i specify the wrong database name, then it connect to any running database.

example: jdbc:postgresql://localhost:5432:test_db22 -user build -password password -c \;

After connection when i do:

select current_database;
it shows: shivani_db.

While I connected to test_db22(which did not exists).


Regards,
Shivani


[WWW] [Yahoo!] aim icon [MSN] [ICQ]
 
Forum Index » Jisql
Go to:   
Powered by JForum 2.1.9 © JForum Team
This site run by Scott Dunbar of Xigole Systems. © 2005-2011 - Scott Dunbar
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners
hotjoe.com, xigole.com, and Scott Dunbar have no affiliation with Oracle