This discussion is archived
2 Replies Latest reply: Aug 2, 2013 4:27 AM by dparhonin RSS

How to authenticate a direct connection via JDBC?

dparhonin Newbie
Currently Being Moderated

Hi everybody,

 

I have the following problem. There are the following DSNs configured in my sys.odbc.ini:

 

NMDS_E=TimesTen 11.2.1 Client Driver

NMDS_D=TimesTen 11.2.1 Driver

...

[NMDS_E]

Driver=/opt/TimesTen/tt1121/lib/libtten.so

DataStore=/var/tmp/NM/NMDS_E

LogDir=/var/tmp/NM

DatabaseCharacterSet=AL32UTF8

PermSize=200

 

[NMDS_D]

Driver=/opt/TimesTen/tt1121/lib/libtten.so

DataStore=/var/tmp/NM/NMDS_E

LogDir=/var/tmp/NM

DatabaseCharacterSet=AL32UTF8

PermSize=200

UID=anmdb_user

PWD=anmdb_user

 

If I try to connect via ttIsql, it works:

connect "DSN=NMDS_D";

Connection successful: DSN=NMDS_D;UID=anmdb_user;DataStore=/var/tmp/NM/NMDS_E;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;DRIVER=/opt/TimesTen/tt1121/lib/libtten.so;LogDir=/var/tmp/NM;PermSize=200;TypeMode=0;

 

But if I try to connect to the NMDS_D via JDBC driver, it fails:

java.sql.SQLException: [TimesTen][TimesTen 11.2.1.8.4 ODBC Driver][TimesTen]TT7001: User authentication failed -- file "db.c", lineno 9718, procedure "sbDbConnect"

        at com.timesten.jdbc.JdbcOdbc.createSQLException(JdbcOdbc.java:3232)

        at com.timesten.jdbc.JdbcOdbc.standardError(JdbcOdbc.java:3381)

        at com.timesten.jdbc.JdbcOdbc.standardError(JdbcOdbc.java:3346)

        at com.timesten.jdbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:796)

        at com.timesten.jdbc.JdbcOdbcConnection.connect(JdbcOdbcConnection.java:1814)

        at com.timesten.jdbc.TimesTenDataSource.getConnection(TimesTenDataSource.java:148)

        ...

The following URL is used for connection:

jdbc:timesten:direct:Driver=/opt/TimesTen/tt1121/lib/libtten.so;DSN=NMDS_D;DataStore=/var/tmp/NM/NMDS_E;ConnectionCharacterSet=AL32UTF8;

 

Could someone help me with this?

 

Best regards,

Dmitriy.

  • 1. Re: How to authenticate a direct connection via JDBC?
    ChrisJenkins Guru
    Currently Being Moderated

    Hi Dmitry,

     

    Point 1. NMDS_E is not a 'client' DSN it is a direct mode DSN the same as NMDS_D and so the line at the start of the sys.odbc.ini fiel shoudl really say:

     

    NMDS_E=TimesTen 11.2.1 Driver


    This issue is not relevant to your current question but could cause you problems in the future if you do not correct it.


    The issue here is that you are providing far too much infomation in the JDBC URL. You are basiccally bypassign what is configured in the sys.odbc.ini file. A 'normal' JDBC connection URL looks like this:


    jdbc:timesten:direct:NMDS_D


    If you try that then it should pick up the UID and PWD from the file. Of course this is terribly insecure and you should never hard code UID or PWD in a file! You should really provide them as part of the JDBC connection call.


    Chris


  • 2. Re: How to authenticate a direct connection via JDBC?
    dparhonin Newbie
    Currently Being Moderated

    Thanks a lot, Chris!

    It helped.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points