When I connect to DB, always connects as tempdb I am trying to run a sybase DB query from a jsp session. 

I can connect to the DB fine, but when I run my query, by default it always runs against tempdb. 

Is there a way I can make a connection to a different DB and not by default connect to tempdb?

The aim is to be able to run a query for any table chosen by the user from a drop down list. I have the dropdown list working and can successfully select any DB. I know this is working as I am storing the DB selected in a variable and can confirm the name selected is always the name I can see in the variable.
It seems the DBA who has created your login has set tempdb as your default database. You may request him/her to do the change at login definition level as per this article. By default, if none of them are mentioned, user connects to master database. You may use below command:

sp_modifylogin login_name, defdb, "your_database"


Kindly note that above command needs to be run at Sybase Database level and only a System Administrator or System Security Officer can execute sp_modifylogin.

As already suggested by Markp, you can issue the command use &lt;database_name&gt; for changing your database. Alternatively you may use database name in the connection string itself.

Below is an example of isql for connecting to "your_database"

isql -S"Server_Name" -U"Login" -D"Your_Database" -P"Password"


You may refer below for isql options:

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc30191.1570100/doc/html/san1367605044069.html

Hope above helps.