DriverManager.getConnection() method error while using Teradatd driver

Connectivity
Enthusiast

DriverManager.getConnection() method error while using Teradatd driver


hi ,

I am new to Teradata. I am trying to connect to Teradata DB using teradata driver. i am getting Error in DriverManager.getConnection() Method. I am not able to understand why this is comming. I have tried with the latest driver avaliable in net for teradata.

String url="jdbc:teradata:///AMRROCD"
Class.forName("com.teradata.jdbc.TeraDriver");
Properties x = new Properties();
x.put("user","xxxx");
x.put("password","xxxx");
Connection con = DriverManager.getConnection (url, x);--> I am getting Null Pointer Exception at this line .

could anyone help me. I am trying to run this code in Unix environment

I am able to execute the same code through windows OS.

i have set classpath for terajdbc4.jar

Thanks in Advance

5 REPLIES
Teradata Employee

Re: DriverManager.getConnection() method error while using Teradatd driver

First, your connection URL is incorrect. You listed 3 slashes in your URL -- jdbc:teradata:///AMRROCD

But you must have only 2 slashes after the second colon in your URL -- it should be jdbc:teradata://AMRROCD

Second, you said "i have set classpath for terajdbc4.jar", but you need tdgssconfig.jar on your classpath also.

You didn't provide the stack trace for your NullPointerException, but if your NullPointerException is occurring at com.teradata.tdgss.jtdgss.TdgssConfigApi.GetMechanisms, then that problem is due to due to tdgssconfig.jar not being available -- either not listed on your classpath, or the file is not present.
Enthusiast

Re: DriverManager.getConnection() method error while using Teradatd driver

hi
Thanks for you reply,
Sorry for the Typo in URL its jdbc:teradata://server ip/AMRROCD.
i configured teh classpath for tdgssconfig.jar. i tried to executet he java code in unix. still i have error. the error is as below.

Exception in thread "main" java.lang.NoClassDefFoundError: javax/management/NotificationListener
at weblogic.xml.jaxp.RegistryDocumentBuilderFactory.(RegistryDocumentBuilderFactory.java:21)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:306)
at java.lang.Class.newInstance(Class.java:259)
at javax.xml.parsers.FactoryFinder.newInstance(FactoryFinder.java:95)
at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:172)
at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:93)
at com.teradata.tdgss.jtdgss.TdgssParseXml.parse(DashoA1*..)
at com.teradata.tdgss.jtdgss.TdgssConfigApi.(DashoA1*..)
at com.teradata.tdgss.jtdgss.TdgssManager.(DashoA1*..)
at com.teradata.tdgss.jtdgss.TdgssManager.getInstance(DashoA1*..)
at com.teradata.jdbc.jdbc.GenericTeraEncrypt.getGSSM(GenericTeraEncrypt.java:583)
at com.teradata.jdbc.jdbc.GenericTeraEncrypt.getConfig(GenericTeraEncrypt.java:601)
at com.teradata.jdbc.jdbc.GenericTeraEncrypt.getUserNameForOid(GenericTeraEncrypt.java:694)
at com.teradata.jdbc.AuthMechanism.(AuthMechanism.java:50)
at com.teradata.jdbc.jdbc.GenericInitDBConfigState.action(GenericInitDBConfigState.java:105)
at com.teradata.jdbc.jdbc.GenericLogonController.run(GenericLogonController.java:49)
at com.teradata.jdbc.jdbc_4.TDSession.(TDSession.java:195)
at com.teradata.jdbc.jdbc_3.ifjdbc_4.TeraLocalConnection.(TeraLocalConnection.java:94)
at com.teradata.jdbc.jdbc.ConnectionFactory.createConnection(ConnectionFactory.java:55)
at com.teradata.jdbc.TeraDriver.doConnect(TeraDriver.java:216)
at com.teradata.jdbc.TeraDriver.connect(TeraDriver.java:149)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at dbValidation.main(dbValidation.java:25)

Enthusiast

Re: DriverManager.getConnection() method error while using Teradatd driver

this is actual scenario

hi I am getting error that is something really wired.

String url="jdbc:teradata://server ip/AMRROCD";
Class.forName("com.teradata.jdbc.TeraDriver");
Connection con =DriverManager.getConnection(url,"user","pwd");--> error at this line

i have configured CLASSPATH for terajdbc4.jar and tdgssconfig.jar. while executing the code i am getting wired error and i am not able to trace why it comming.

the same code worked in my local system which is windows. the same code in Unix system throws error. Path has been configured in UNIX .

initially i configured terajdbc4.jar in classpath so i got error -->
-----------------------------------------------------------------------------------------------------------------------------------------------------
GSSException: Failure unspecified at GSS-API level (Mechanism level: UserFile parameter null)
at com.teradata.tdgss.jtdgss.TdgssParseXml.(DashoA1*..)
at com.teradata.tdgss.jtdgss.TdgssConfigApi.(DashoA1*..)
at com.teradata.tdgss.jtdgss.TdgssManager.(DashoA1*..)
at com.teradata.tdgss.jtdgss.TdgssManager.getInstance(DashoA1*..)
at com.teradata.jdbc.jdbc.GenericTeraEncrypt.getGSSM(GenericTeraEncrypt.java:583)
at com.teradata.jdbc.jdbc.GenericTeraEncrypt.getConfig(GenericTeraEncrypt.java:601)
at com.teradata.jdbc.jdbc.GenericTeraEncrypt.getUserNameForOidGenericTeraEncrypt.java:694)
at com.teradata.jdbc.AuthMechanism.(AuthMechanism.java:50)
at com.teradata.jdbc.jdbc.GenericInitDBConfigState.action(GenericInitDBC
onfigState.java:105)
at com.teradata.jdbc.jdbc.GenericLogonController.run(GenericLogonControl
ler.java:49)
at com.teradata.jdbc.jdbc_4.TDSession.(TDSession.java:195)
at com.teradata.jdbc.jdbc_3.ifjdbc_4.TeraLocalConnection.(TeraLoca
lConnection.java:94)
at com.teradata.jdbc.jdbc.ConnectionFactory.createConnection(ConnectionF
actory.java:55)
at com.teradata.jdbc.TeraDriver.doConnect(TeraDriver.java:216)
at com.teradata.jdbc.TeraDriver.connect(TeraDriver.java:149)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at dbValidation.main(dbValidation.java:27)
Error java.lang.NullPointerException
-----------------------------------------------------------------------------------------------------------------------

i got information from net that we need to configure tdgssconfig.jar too in classpath. after configuring the classpath for tdgssconfig.jar while executing i am getting error as below
-------------------------------------------------------------------------------------------------------------------
Exception in thread "main" java.lang.NoClassDefFoundError: javax/management/NotificationListener
at weblogic.xml.jaxp.RegistryDocumentBuilderFactory.(RegistryDocumentBuilderFactory.java:21)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:306)
at java.lang.Class.newInstance(Class.java:259)
at javax.xml.parsers.FactoryFinder.newInstance(FactoryFinder.java:95)
at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:172)
at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:93)
at com.teradata.tdgss.jtdgss.TdgssParseXml.parse(DashoA1*..)
at com.teradata.tdgss.jtdgss.TdgssConfigApi.(DashoA1*..)
at com.teradata.tdgss.jtdgss.TdgssManager.(DashoA1*..)
at com.teradata.tdgss.jtdgss.TdgssManager.getInstance(DashoA1*..)
at com.teradata.jdbc.jdbc.GenericTeraEncrypt.getGSSM(GenericTeraEncrypt.java:583)
at com.teradata.jdbc.jdbc.GenericTeraEncrypt.getConfig(GenericTeraEncrypt.java:601)
at com.teradata.jdbc.jdbc.GenericTeraEncrypt.getUserNameForOid(GenericTeraEncrypt.java:694)
at com.teradata.jdbc.AuthMechanism.(AuthMechanism.java:50)
at com.teradata.jdbc.jdbc.GenericInitDBConfigState.action(GenericInitDBConfigState.java:105)
at com.teradata.jdbc.jdbc.GenericLogonController.run(GenericLogonController.java:49)
at com.teradata.jdbc.jdbc_4.TDSession.(TDSession.java:195)
at com.teradata.jdbc.jdbc_3.ifjdbc_4.TeraLocalConnection.(TeraLocalConnection.java:94)
at com.teradata.jdbc.jdbc.ConnectionFactory.createConnection(ConnectionFactory.java:55)
at com.teradata.jdbc.TeraDriver.doConnect(TeraDriver.java:216)
at com.teradata.jdbc.TeraDriver.connect(TeraDriver.java:149)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at dbValidation.main(dbValidation.java:27)

does anybody have faced similar issue

its very urgent for me to get rid of this
Teradata Employee

Re: DriverManager.getConnection() method error while using Teradatd driver

Your stack trace shows the NoClassDefFoundError occurring from a WebLogic class file.

I see the WebLogic class file listed in your stack trace, but your stack trace also appears to indicate that you are running a command-line Java program.

Have you listed some WebLogic jars, but not others, on the classpath of your command-line Java program?
Enthusiast

Re: DriverManager.getConnection() method error while using Teradatd driver

I have weblog.jar file listed in classpath dir. the dir structue is like below
the dir where jars are stored is -->/opt/egate4.5/egatetst/client505/classes
classes
|__TeraJDBC
| |__terajdbc4.jar
| |__tdgssconfig.jar
|__weblogic.jar
|__weblogic (its a directory)
|__config.properties

i need to access the config.properties file from classes dir and teradrivers from TeraJDBC dir.

when i set CLASSPATH as /opt/egate4.5/egatetst/client505/classes:/opt/egate4.5/egatetst/client505/classes/TeraJDBC/terajdbc4.jar:/opt/egate4.5/egatetst/client505/classes/TeraJDBC/tdgssconfig.jar.

i will get the error as mentioned above.
i need to access the property file from the same location .cant change it because irs accessed by other application.

I am not getting clue how weblogic.xml.jaxp.RegistryDocumentBuilderFactory class is getting invoked here .

do you have any tips on that so i can look into that