|
Here an example that handle both cases:
//Connect to DB
try {
try {
if ( getSQLDatabaseUser().trim() == "" )
sqlConnection =
DriverManager.getConnection( getSQLDatabaseURL() ); // Try with default user
else
sqlConnection =
DriverManager.getConnection( getSQLDatabaseURL(), getSQLDatabaseUser(),
getSQLDatabasePassword() );
}
catch ( Throwable th ) {
// Display DatabaseLogonDialog
DatabaseLogonDialog dld = new
DatabaseLogonDialog( dftFrame, true );
String userId = getSQLDatabaseUser();
boolean logonOk = false;
while ( ! logonOk ) {
try {
dld.getUserIdTextField().setText( userId );
dld.setVisible( true ); //
isModal
userId =
dld.getSelectedUser().getId();
sqlConnection =
DriverManager.getConnection(
getSQLDatabaseURL(),
userId,
dld.getSelectedUser().getPassword() );
logonOk = true;
} catch ( Throwable th1 ) {
logonOk = false;
System.out.println(
"SQL Connection problem: ");
th1.printStackTrace();
dld.getMessageText().setText( th1.toString() );
}
}
}
} catch ( Throwable th ) {
sisaUtil.misc.Tools.handleException( th );
}
On Fri, 27 Oct 2000 13:12:09 +0100, mandy.shaw@uk.catalyst-solutions.com wrote:
>That's probably why it's making you specify userid and password.
>If you are able to use the DB2 JDBC driver (i.e. DRDA), you don't need to
>specify a userid and password, null parameters will do, it just runs under
>whatever is the default user profile for the DRDA link - if *LOCAL the user
>profile of your job, if SNA the default for the appopriate mode's comms
>entry at the target. If TCP/IP DRDA link my experience is that you do need
>a userid/password, but others may be able to help.
>If you're doing a *local* Toolbox connection you may be able to get away
>with null userid and password too - anyone able to comment?
>Mandy
>
>
>
>
>
>Marco_Van_Maris@ept.lu on 10/27/2000 12:36:47 PM
>
>Please respond to JAVA400-L@midrange.com
>
>To: JAVA400-L@midrange.com
>cc: (bcc: Mandy Shaw/Pacific/UK)
>Subject: Re: JDBC : How to handle user-id and password
>
>
>
>
>
>
>I am using the Toolbox JDBC driver.
>
>marco
>
>
>
>
>
>mandy.shaw@uk.catalyst-solutions.com on 27/10/2000 13:04:37
>
>Please respond to JAVA400-L@midrange.com
>
>To: JAVA400-L@midrange.com
>cc: (bcc: Marco Van Maris/EPT)
>
>Subject: Re: JDBC : How to handle user-id and password
>
>
>
>
>Are you using the DB2 or the Toolbox JDBC driver? The situation varies
>depending on the answer to this.
>
>
>
>
>
>Marco_Van_Maris@ept.lu on 10/27/2000 10:28:29 AM
>
>Please respond to JAVA400-L@midrange.com
>
>To: JAVA400-L@midrange.com
>cc: (bcc: Mandy Shaw/Pacific/UK)
>Subject: JDBC : How to handle user-id and password
>
>
>
>
>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Franco Biaggi">
<meta name="GENERATOR" content="Franco Biaggi">
</head>
<body>
<p> </p>
<table BORDER="1" COLS="1" WIDTH="452" BGCOLOR="#FFFF00">
<tr>
<td width="446"><font face="Comic Sans MS"><small><small><br>
<font color="#3333FF"><a href="http://www.ticino.com/usr/fbiaggi/">Franco
Biaggi</a></font><small><br>
<font color="#3333FF"><a href="http://www.sisa.ch">SISA Studio Informatica
SA</a></font><small><small><small> <br>
</small></small></small><font color="#3333FF">R&D
Services</font><small><small><small>
<br>
</small></small></small><font color="#3333FF">Via Carvina
1</font><small><small><small> <br>
</small></small></small><font color="#3333FF">CH-6807
Taverne</font><small><small><small> <br>
</small></small></small><font color="#3333FF">Tel. +41 91 935 75 35
Fax. +41 91 935
75 30</font></small></small></small><br>
</small></small></small><font
color="#3333FF">ICQ:59714125(disabled)</font><small><small><small> <br>
</font></td>
</tr>
</table>
</body>
</html>
+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.