1

I have setup a Timesten client(11.2.2.8.0) on my unix machine.

I have setup a Timesten server on different machine.

After setup is complete I am trying to connect to Timesten database using JDBC from my spark code written in java.

I am getting below exception :

Exception in thread "main" java.sql.SQLException: [TimesTen][TimesTen 11.2.2.8.0 CLIENT]Cannot find the requested DSN (ormb_ttdb) in ODBCINI /var/TimesTen/tt1122/sys.odbc.ini or  /var/TimesTen/sys.odbc.ini
        at com.timesten.jdbc.JdbcOdbc.createSQLException(JdbcOdbc.java:3237)
        at com.timesten.jdbc.JdbcOdbc.standardError(JdbcOdbc.java:3386)
        at com.timesten.jdbc.JdbcOdbc.standardError(JdbcOdbc.java:3351)
        at com.timesten.jdbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:800)
        at com.timesten.jdbc.JdbcOdbcConnection.connect(JdbcOdbcConnection.java:1866)
        at com.timesten.jdbc.TimesTenDriver.connect(TimesTenDriver.java:305)
        at com.timesten.jdbc.TimesTenDriver.connect(TimesTenDriver.java:161)
        at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anonfun$createConnectionFactory$1.apply(JdbcUtils.scala:63)
        at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anonfun$createConnectionFactory$1.apply(JdbcUtils.scala:54)
        at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:63)
        at org.apache.spark.sql.execution.datasources.SaveIntoDataSourceCommand.run(SaveIntoDataSourceCommand.scala:46)
        at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:70)
        at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:68)
        at org.apache.spark.sql.execution.command.ExecutedCommandExec.doExecute(commands.scala:86)
        at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:131)
        at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:127)
        at org.apache.spark.sql.execution.SparkPlan$$anonfun$executeQuery$1.apply(SparkPlan.scala:155)
        at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
        at org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:152)
        at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:127)
        at org.apache.spark.sql.execution.QueryExecution.toRdd$lzycompute(QueryExecution.scala:80)
        at org.apache.spark.sql.execution.QueryExecution.toRdd(QueryExecution.scala:80)
        at org.apache.spark.sql.DataFrameWriter$$anonfun$runCommand$1.apply(DataFrameWriter.scala:654)
        at org.apache.spark.sql.DataFrameWriter$$anonfun$runCommand$1.apply(DataFrameWriter.scala:654)
        at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:77)
        at org.apache.spark.sql.DataFrameWriter.runCommand(DataFrameWriter.scala:654)
        at org.apache.spark.sql.DataFrameWriter.saveToV1Source(DataFrameWriter.scala:273)
        at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:267)
        at com.sample.Transformation.main(Transformation.java:194)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
        at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:879)
        at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:197)
        at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:227)
        at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:136)
        at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)

I have set correct values of TTC_SERVER and TTC_SERVER_DSN in sys.odbc.ini file at /var/TimesTen and /var/TimesTen/tt1122 locations.

Can someone explain the reason?

EDIT

sys.odbc.ini

# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 

########################################################################
# This following sample definitions should be in the .odbc.ini file
# that is used for the TimesTen 11.2.2 Client.
# The Server Name is set in the TTC_SERVER attribute.
# The Server DSN is set in the TTC_SERVER_DSN attribute.
#########################################################################

[ODBC Data Sources]
#sampledbCS_1122=TimesTen 11.2.2 Client Driver
#cachedb1CS_1122=TimesTen 11.2.2 Client Driver
#repdb1CS_1122=TimesTen 11.2.2 Client Driver
#repdb2CS_1122=TimesTen 11.2.2 Client Driver

#[sampledbCS_1122]
TTC_SERVER=<SERVER's HOSTTNAME>
TTC_SERVER_DSN=ormb_ttdb

#[cachedb1CS_1122]
#TTC_SERVER=SERVER's HOSTTNAME
#TTC_SERVER_DSN=cachedb1_1122

#[repdb1CS_1122]
#TTC_SERVER=SERVER's HOSTTNAME
#TTC_SERVER_DSN=repdb1_1122

#[repdb2CS_1122]
#TTC_SERVER=SERVER's HOSTTNAME
#TTC_SERVER_DSN=repdb2_1122

My connection String in spark code :

String ttConnection = "jdbc:timesten:client:dsn=<DSN_NAME>;UID=<USER_NAME>;PWD=<PASSWORD>";
Curious Techie
  • 185
  • 2
  • 15
  • Please show the contents of those `sys.odbc.ini` files – Mark Rotteveel Sep 25 '18 at 13:14
  • @MarkRotteveel I have added contents of sys.odbc.ini files – Curious Techie Sep 26 '18 at 04:58
  • @MarkRotteveel Am I missing anything here? – Curious Techie Sep 26 '18 at 05:42
  • Yes, you don't have a definition for the `ormb_ttdb` DSN, as indicated in the error message. I also hope you realise that `#` is a comment mark in `ini` files. – Mark Rotteveel Sep 26 '18 at 08:17
  • @MarkRotteveel i have entry for ormb_ttdb in actual file, i have just replaced it here for the display purpose. I understand # is a comment and first two entries are not commented for same purpose – Curious Techie Sep 26 '18 at 08:57
  • The second entry **is** commented, in ini files, section are started with `[name-of-section]`, and the second section is commented out. And really, your question should be consistent. If the error complains about `ormb_ttdb`, then you shouldn't rename it from the file (by all means, anonymize the config value, but the entry should be there). – Mark Rotteveel Sep 26 '18 at 09:01
  • You have **no** DSN entries in that file, because all sections (except `ODBC Data Sources`) are commented out. – Mark Rotteveel Sep 26 '18 at 09:05
  • @MarkRotteveel TTC_SERVER= TTC_SERVER_DSN=ormb_ttdb These are uncommented entrues which specifies DSN. – Curious Techie Sep 26 '18 at 09:06
  • @MarkRotteveel for sampledbCS_1122 I have uncommented entries. – Curious Techie Sep 26 '18 at 09:07
  • You don't seem to understand the ini-file format. The line `#[sampledbCS_1122]` means that section is commented out, which makes those config values part of the `[ODBC Data Sources]` section where they are meaningless. – Mark Rotteveel Sep 26 '18 at 09:07
  • @MarkRotteveel yes I am not very familiar with .ini files you are right so should I uncomment #[sampledbCS_1122] and try? – Curious Techie Sep 26 '18 at 09:08
  • Yes you should uncomment that, and possibly also its entry under `[ODBC Data Sources]` – Mark Rotteveel Sep 26 '18 at 09:09
  • @MarkRotteveel Thanks sure I will do that, do I have to change [sampledbCS_1122] this name to something else or it doesnt matter? – Curious Techie Sep 26 '18 at 09:12
  • That is the local DSN name that you should use in your connection string. – Mark Rotteveel Sep 26 '18 at 09:13
  • @MarkRotteveel so my connection string will be like : String ttConnection = "jdbc:timesten:client:dsn=sampledbCS_1122;UID=;PWD="; instead of String ttConnection = "jdbc:timesten:client:dsn=ormb_ttdb;UID=;PWD="; , is it so? – Curious Techie Sep 26 '18 at 09:15
  • I suggest you read the [documentation](https://docs.oracle.com/cd/E11882_01/timesten.112/e21638/writing_app.htm#TTJDV128) – Mark Rotteveel Sep 26 '18 at 09:18
  • @MarkRotteveel sure thanks – Curious Techie Sep 26 '18 at 09:20
  • After using connection String : jdbc:timesten:client:dsn=sampledbCS_1122;UID=;PWD= , I am getting error : java.lang.ClassNotFoundException: com.timesten.jdbc.TimesTenDriver at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424)...... – Curious Techie Sep 26 '18 at 10:08
  • @MarkRotteveel LD_LIBRARY_PATH is already set on client. still getting va.lang.ClassNotFoundException: com.timesten.jdbc.TimesTenDriver – Curious Techie Sep 26 '18 at 10:16
  • @MarkRotteveel do i need to set LD_LIBRARY_PATH on server as well? – Curious Techie Sep 26 '18 at 10:37

0 Answers0