Hi I have a java application connecting to a MS SQL Server database. I set up an ODBC connection in "Windows ODBC Data Source Administrator" using its SQL Server driver. I have no problems connecting and all SQL executes fine. I use the following driverManager: "sun.jdbc.odbc.JdbcOdbcDriver" and connectionString: "jdbc dbc atasourcename" However, it only seems to work if I define the username & password with the connection string. I do not want to define the password in the java application or any config file but in the ODBC data source. The Windows ODBC Data Source Administrator (SQL Server driver) allows you to select "Connect to SQL Server to obtain default settings for the additional configuration options". It allows one to enter a 'Login ID' & 'Password'. Then one can proceed and test the connection. I define the LoginId & Password and test the connection successfully. But when I access the database through the Java application it fails with the following error: java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection. To me it appears that the ODBC data source's Userid & password is not being applied when the connection is created. Is there anyway one can configure this so that the userid & password does not have to be defined with the connection string in the java application when the connection is created?
I don't believe you can get ODBC to work that way - you'll have to supply the userid and password if using a straight java application. However, if you use J2EE and connect through a registered datasource with JNDI then it should be possible. If its a web app, most application servers allow you to connect with just the datasource name. The userid and password is set in a user registered datasource with the application server. [ January 27, 2004: Message edited by: Lu Battist ]