473,605 Members | 2,520 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

jdbc connection without giving username and password

When using embedded SQL for db2 under solaris, you do not need to give
username and password since the system will use your unix-login as
default credential. However, with JDBC seems I always need to provide
username and password, the Java API
DriverManger.ge tConnection(Str ing url) does not work. I am not sure
if this is because the JDBC driver, or because it does not work for
DB2 under solaris. Any comments? Thanks a lot!

Mar 30 '07 #1
3 10231
%NAME% wrote:
When using embedded SQL for db2 under solaris, you do not need to give
username and password since the system will use your unix-login as
default credential. However, with JDBC seems I always need to provide
username and password, the Java API
DriverManger.ge tConnection(Str ing url) does not work. I am not sure
if this is because the JDBC driver, or because it does not work for
DB2 under solaris. Any comments? Thanks a lot!
As far as I remember it depends on the driver.

com.ibm.db2.jdb c.app can use the credentials of the OS (if the DB2
client is installed), com.ibm.db2.jdb c.net needs user/password.

It may have changed in DB2 v9 and the unified driver.

Bernd

--
Well, there's egg and bacon; egg sausage and bacon; egg and
tr**********@sp amonly.de; egg bacon and spam; egg bacon sausage
and tr**********@sp amonly.net; spam bacon sausage and spam; spam
egg spam spam bacon and tr**********@ni xwill.de ; spam sausage
Mar 30 '07 #2
Not quite true for embedded SQL. Bind parameters control which userid
will be used when executing the package; the binder or the user. You are
correct that it will pickup your userid and password from your session.

JDBC is dynamic and requires a userid and password to determine the
user's privileges. I recall JDBC using my session values for type 2
connections but have always needed to supply them when using type 4
(JDBC Universal driver) connections.

The Universal JDBC DriverManager interface has a "securityMechan ism"
facility if you make your connection using the getConnection variant
that includes a java.util.prope rties parameter. Unfortunately, you can't
eliminate the need to supply at least a userid unless you are using full
KERBEROS security. See the "Programmin g Client Applications" manual
section "Security under the Universal JDBC Driver". My copy has this
information om page 444.

Phil Sherman

%NAME% wrote:
When using embedded SQL for db2 under solaris, you do not need to give
username and password since the system will use your unix-login as
default credential. However, with JDBC seems I always need to provide
username and password, the Java API
DriverManger.ge tConnection(Str ing url) does not work. I am not sure
if this is because the JDBC driver, or because it does not work for
DB2 under solaris. Any comments? Thanks a lot!
Mar 30 '07 #3
Ian
%NAME% wrote:
When using embedded SQL for db2 under solaris, you do not need to give
username and password since the system will use your unix-login as
default credential. However, with JDBC seems I always need to provide
username and password, the Java API
DriverManger.ge tConnection(Str ing url) does not work. I am not sure
if this is because the JDBC driver, or because it does not work for
DB2 under solaris. Any comments? Thanks a lot!
The security mechanism has nothing to do with embedded SQL vs JDBC.
It is a function of whether you are connecting to a local or remote
database (and the AUTHENTICATION parameter on the database server).
For this discussion, let's assume that AUTHENTICATION = SERVER, which
is the default).

Your embedded application doesn't require a password because the
database alias is a local database (the connection is made via
shared memory).

If you were to catalog the database as a "remote" database, as in:

catalog tcpip node x remote 127.0.0.1 server 50000;
catalog database sample as rsample at node x;

And you application tries to connect to 'rsample' with no user and
password, it will fail. This is because DB2 now sees you connecting
via TCPIP.

Likewise, with JDBC: Type 2 JDBC drivers depend on the database
directory. Therefore, if the entry in the database directory is
for a local database, you can connect with no userid/password.

Type 4 JDBC drivers always use a remote connection, and therefore
you must specify a username and password.
The old "app" driver (com.ibm.db2.jd bc.app.DB2Drive r) supports Type 2
connectivity only. It is deprecated in V9.

The "Universal" driver (com.ibm.db2.jc c.DB2Driver) supports *both*
Type-2 and Type-4 connectivity. Which you use depends on the URL
that you send to the getConnection() routine:

jdbc:db2:sample --Type 2
jdbc:db2://127.0.0.1:50000/sample --Type 4
If you use type-2 connectivity AND the entry in the database directory
is local, then you do not need to specify a user and password.

Mar 30 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4237
by: Robert Mazur | last post by:
MySQL 5.0 alpha (binary install) on Solaris 9 -or- RedHat 8.0 mysql-connector-java-3.0.8-stable ----------------------- Is there something different going on with JDBC and the alpha version of MySQL 5.0? When trying to connect I am getting: ** BEGIN NESTED EXCEPTION **
2
5267
by: Marc Stiegele | last post by:
Hello, I have a problem with the IBM DB2 UDB XML Extender. I`m working on a iSeries 400 server (AS/400, V5R1) with a integrated DB2 (my client is NT 4.0 Service Pack 1 with JDK1.1.8). I want to create XML files out of the DB2 data using the XML collections method and SQL mapping. I successfully enabled my database, put the collection.dtd into DTD_REF, created a DAD file and enabled the collection (xcolltest01) using the OS/400 command...
2
9216
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered problems doing this. I wanted to implemented a generic "Helper" class like this: /** * Helper
3
13364
by: r_stringer66 | last post by:
Hi, I am trying to connect to a db2 database via a jdbc application and this is the following error I get: Exception : CLI0615E Error receiving from socket, server is not responding. SQLSTATE=08S01 Below is the following code I am using. I did not specify the port number but even when I try specify it I get the same error.
2
2176
by: Phil Campaigne | last post by:
Hi All, I am seting up my web app with a tomcat/postgresql hosting service. From my psql client I type psql and then I am asked for my password. This logs me into my hosted database just fine. However, I can't log on from my webapp to the database thru jdbc like I could when my webapp/Tomcat/postgresql were on my local machine. The jdbc class only has a method with 3 parameters, url, user, password parameters. The hosting server is...
1
2014
by: nielsgron | last post by:
Hi, I am using the DB2 Type 4 JDBC Driver to connect to my DB2 8.2 for Windows server. Everything works perfectly unless I have a password with the pipe character ( "|" ) in it. The server password has a "|" character in it. If I do this, I get an exception stating that the password is invalid. This is what I execute ...
2
5953
by: %NAME% | last post by:
(Thanks to Bernd, Ian, Phil last time for their detailed answers last time) Now I try to call JDBC driver without giving the username and password as they suggested. I am using DB2 jdbc on SunOS 5.8 with db2 version 7.2.0. When I am using the type2 network driver (COM.ibm.db2.jdbc.net.DB2Driver) with username and password, everything is fine. However, when I use the application driver: (COM.ibm.db2.jdbc.app.DB2Driver), and call...
1
4567
by: Debabrata Jana | last post by:
Please go through the JAVA code below: class Main{ public Connection getConnection(){ Connection l_con = null; try { String hostname = "172.10.23.1:1527"; //Host IP:port No String dbsid = "TESTSID"; //SID Name or Service Name String username = "TESTUSER"; //Database user String password = "password"; //User password
2
2342
by: kierandes | last post by:
Hi Guy, I am using a JDBC connection to retrieve data and populate datasets. Having some problems with errors: Error: java.sql.SQLException: Invalid cursor state // now we can get the connection from the DriverManager Connection con = DriverManager.getConnection(database ,"",""); //String searchPatients = G.PatientSearch.getText(); // We are connected, so lets create a statement to ask for...
0
7999
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8423
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8411
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8281
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5885
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3911
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2437
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1270
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.