• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

jdbc:odbc password definition

Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
    Bookmark Topic Watch Topic
  • New Topic