Pregunta

I am connecting to Sybase ASE with JDK7u25 and JConnect_JDBC3.jar (it appears to be Sybase JDBC version 6.0).

My URL is as follows:

jdbc:sybase:Tds:MYSERVER:5004/myDB

I can connect to the server without any problem.

However, even if I specify the wrong database name in the URL as below, I am able to connect:

jdbc:sybase:Tds:MYSERVER:5004/myDBaa

OR

jdbc:sybase:Tds:MYSERVER:5004/wrongDB

OR

jdbc:sybase:Tds:MYSERVER:5004/

So why it allows to connect me if I specify incorrect or no database name in the URL?

¿Fue útil?

Solución

You are successfully connecting to the server, but I suspect that after your connection is open, if you checked the database you were connected to, it would list master.

As long as the user you are connecting as is a valid user (or a member of a valid group like public) in the master database, your connection will succeed - just not to the correct db. If you change the default db of the user to myDB, than an attempt to connect to an invalid DB will default them back to myDB.

**The following could break stuff - proceed at your own risk**

It is possible to drop the guest user from master, but it can not be done via sp_dropuser.

First you have to enable manual updates to system tables:

sp_configure 'allow udpates to system tables', 1

Next you will manually delete the guest user from master..sysusers

delete from master..sysusers where name = "guest"

Lastly turn off manual updates to system tables to preven accidental damage:

sp_configure 'allow updates to system tables', 0

This should prevent users from connection to your system if they don't specify the correct database. It will also prevent users from connecting who have not been given permissions to thier default database.

If you need to undo this change, just add the guest user back to the master db:

sp_adduser guest
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top