DB2 connection without specifying username and password

随声附和 提交于 2019-12-13 06:59:57

问题


I have installed DB2 Express C 9.7.4 edition.

I am establishing DB2 Connection using JAVA language.

But I have to still provide user name and password of my windows Login account for establishing connection...

Is it necessary to mention it ?

Is there any way out that can establish connection without specifying user name/password as during installation we have skipped the page.

Thanks in advance...


回答1:


When an application runs on the same machine as the database server, DB2 will make the assumption that the userID that started the application has already been authenticated by the operating system – so no additional authentication is necessary. This is referred to as impicit authentication.

So, without making changes to the default DB2 database configuration, you can do this if the following conditions are met:

  1. The java application must be running on the same machine as the DB2 database

  2. Your application must use a JDBC Type 2 connection (JDBC URL should look like jdbc:db2:database – not jdbc://localhost:50000/database).

  3. The userID executing the Java application has authority to connect to the DB2 database, query the appropriate tables, etc.

It is possible to allow implicit authentication for applications running on machines other than the database server, but this requries setting up trusted contexts or opening a big security hole (changing the AUTHENTICATION database configuration parameter).




回答2:


The option that you mention in the screenshot is just to indicate the way the instance and other services are started. It does not mean the authentication mechanism used in DB2.

In order to permit an unknown user to connect to the database, you have to grant "connection" to public group. By doing this, any user could connect to the database, and it is not necessary to give the credentials.

db2 GRANT CONNECT ON DATABASE TO PUBLIC

For more information: http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0050616.html



来源:https://stackoverflow.com/questions/8291677/db2-connection-without-specifying-username-and-password

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!