weblogic oracle jdbc SQLException: The database session time zone is not set - oracle11g

After years running our app without issues, this week we get java.sql.SQLException: The database session time zone is not set each time the app reads a row from the database that has a column of type TIMESTAMP WITH LOCAL TIME ZONE.
Server: WebLogic 10.3.3
JRE: jrockit-jdk1.6.0_26-R28.1.4-4.0.1
Oracle database : 11.2.0.4.0
Stack trace:
Caused by: java.sql.SQLException: The database session time zone is not set
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70) ~[ojdbc6.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133) ~[ojdbc6.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199) ~[ojdbc6.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:263) ~[ojdbc6.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:271) ~[ojdbc6.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:445) ~[ojdbc6.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
at oracle.jdbc.driver.TimestampltzAccessor.getTimestamp(TimestampltzAccessor.java:298) ~[ojdbc6.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
at oracle.jdbc.driver.OracleResultSetImpl.getTimestamp(OracleResultSetImpl.java:1060) ~[ojdbc6.jar:Oracle JDBC Driver version - "11.1.0.7.0-Production"]
at weblogic.jdbc.wrapper.ResultSet_oracle_jdbc_driver_OracleResultSetImpl.getTimestamp(Unknown Source) ~[com.bea.core.utils.wrapper_1.4.0.0.jar:1.8.0.0]
at org.springframework.jdbc.support.JdbcUtils.getResultSetValue(JdbcUtils.java:183) ~[spring-jdbc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.jdbc.core.BeanPropertyRowMapper.getColumnValue(BeanPropertyRowMapper.java:308) ~[spring-jdbc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.jdbc.core.BeanPropertyRowMapper.mapRow(BeanPropertyRowMapper.java:246) ~[spring-jdbc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:92) ~[spring-jdbc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.processResultSet(JdbcTemplate.java:1144) ~[spring-jdbc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.extractOutputParameters(JdbcTemplate.java:1104) ~[spring-jdbc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate$5.doInCallableStatement(JdbcTemplate.java:1015) ~[spring-jdbc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate$5.doInCallableStatement(JdbcTemplate.java:1) ~[spring-jdbc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:953) ~[spring-jdbc-3.0.5.RELEASE.jar:3.0.5.RELEASE]
... 88 common frames omitted
I tried adding SQL ALTER SESSION SET TIME_ZONE='+01:00' as Init SQL in the WebLogic datasource definition, but it does not seem to help.
Help!

Related

Simba Athena ODBC Driver: Can't Connect on a Mac

I'm trying to connect to AWS Athena using Simba Athena ODBC in r.
DBI::dbConnect(
odbc::odbc(),
driver = "Simba Athena ODBC Driver",
S3OutputLocation = <>,
AwsRegion = "us-east-2",
AuthenticationType = "IAM Credentials",
Schema = <>,
AWS_ACCESS_KEY_ID = <>,
AWS_SECRET_ACCESS_KEY = <>)
Error: nanodbc/nanodbc.cpp:1021: 00000: [Simba][ODBC] (11560) Unable to locate SQLGetPrivateProfileString function: [Simba][DSI] An error occurred while attempting to retrieve the error message for key 'LibsLoadErr' with message parameters ['""'] and component ID 3: Message not found in file "/Library/simba/athenaodbc/ErrorMessages/en-US/ODBCMessages.xml"
I've updated my ODBC driver to route to the correct file per this question - Simba Athena ODBC: unable to use SQLGetPrivateProfileString functions
I am also getting a response from the odbc:odbcListDrivers() function:
name attribute value
ODBC Drivers Simba Athena ODBC Driver Installed
Simba Athena ODBC Driver Description. Simba Athena ODBC Driver
Simba Athena ODBC Driver Driver. /Library/simba/athenaodbc/lib/libathenaodbc_sb64.dylib

R mssql Invalid Connection String

I have a docker container that contains a database which I'm able to access with the user id and password below and am running into an error when attempting to connect using this code:
con <- DBI::dbConnect(odbc::odbc(),
Driver = "ODBC Driver 17 for SQL Server",
Port = 1433,
Server = "localhost",
Database = "master",
UID = "sa",
PWD = "password!23")
The error is:
Error: nanodbc/nanodbc.cpp:1021: 00000: [Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection [Microsoft][ODBC Driver 17 for SQL Server]Invalid connection string attribute
Any ideas on what the issue could be?
Computer specs:
MacBook Pro (16-inch 2019)
OS: macOS Monterey (version 12.2.1)
Processor: 2.3 GHz 8-Core Intel Core i9
Memory: 16GB 2667MHz DDR4
Startup Disk: Macintosh HD
Graphics: AMD Radeon Pro 5500M 4 GB
Rstudio Version: 2021.09.0 Build 351
OpenSSL Version: 1.1
EDIT:
Switching the code such that the server references 127.0.0.1, 1433 fixed the latter error, but now I'm receiving the former:
Error: nanodbc/nanodbc.cpp:1021: 00000: [Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection
Code used to attempt to create connection:
con <- DBI::dbConnect(odbc::odbc(),
driver = "ODBC Driver 17 for SQL Server",
server = "127.0.0.1,1433",
database = "master",
uid = "sa",
pwd = "password!23")
Docker command used to run the container:
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=password!23' -p '1433:1433' --name sql3 -d mcr.microsoft.com/mssql/server:2017-latest
Container attributes (docker ps --no-trunc):
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f755291fe369f9ad3339626528999bb7cef3d7947e68045b60fc4591f865aace mcr.microsoft.com/mssql/server:2017-latest "/opt/mssql/bin/nonroot_msg.sh /opt/mssql/bin/sqlservr" 24 minutes ago Up 41 seconds 0.0.0.0:1433->1433/tcp sql3
I don't have incontrovertible proof that it was Monterey 12.2.1 that was giving me problems, but downgrading to Big Sur 11.6.4 did resolve my issue (and gave me an opportunity to install dependencies in a more conscientious way).
Thanks everyone for your guidance!

Problems Connecting to Database within Docker Image via RStudio using DBI

I'm attempting to connect to a database within a local Docker image I've spun up using DBI and am running into some pretty cryptic errors... I've successfully started the Docker container (below shows result of docker ps -a):
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
131ab042012c mcr.microsoft.com/mssql/server:2017-latest "/opt/mssql/bin/nonr…" 27 minutes ago Up 27 minutes 127.0.0.1:1433->1433/tcp admiring_northcutt
I then try to connect via:
pool<- pool::dbPool(odbc::odbc(),
Driver = "ODBC Driver 17 for SQL Server",
Server = "localhost",
Database = "master",
UID = "sa",
PWD = "***********",
Port = 1433)
and receive the error:
Error: nanodbc/nanodbc.cpp:1021: 00000: [Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection [Microsoft][ODBC Driver 17 for SQL Server]Invalid connection string attribute
Checking my odbc driver using odbc::odbcListDrivers() returns the output below, so the drivers seem to be present.
name attribute value
1 ODBC Driver 17 for SQL Server Description Microsoft ODBC Driver 17 for SQL Server
2 ODBC Driver 17 for SQL Server Driver /usr/local/lib/libmsodbcsql.17.dylib
3 ODBC Driver 17 for SQL Server UsageCount 2
In addition, executing the container and attempting to connect to the database via the commands:
docker exec -it <container-name> /bin/bash
/opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U sa -P '<password>'
EDIT: The above method now works and I'm able to actively query within the database. I know that the error can't be due to invalid login credentials because I'm using the same exact ones as I ran above in the container.
This same process works for a coworker, so I'm wondering if it's a local issue with my set up. We already compared our .ini files as suggested in this link and they're identical, I've clean re-installed Docker, and I've even ran the coworker's identical container with no luck. Any ideas what could be happening here?
Computer specs:
MacBook Pro (16-inch 2019)
OS: macOS Monterey (version 12.2.1)
Processor: 2.3 GHz 8-Core Intel Core i9
Memory: 16GB 2667MHz DDR4
Startup Disk: Macintosh HD
Graphics: AMD Radeon Pro 5500M 4 GB
Rstudio Version: 2021.09.0 Build 351
OpenSSL Version: 1.1

java.sql.SQLException: [TimesTen]Cannot find the requested DSN (ormb_ttdb) in ODBCINI /var/TimesTen/tt1122/sys.odbc.ini or /var/TimesTen/sys.odbc.ini

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>";

ODBC Connection to Microsoft Azure SQL "The server does not support SSL"

I am trying to establish a connection to a Microsoft Azure SQL database using an ODBC connection (IBM Datastage v11.5) but I get the following error:
Connection failed
ODBC function "SQLConnect" reported: SQLSTATE=HY000: Native Error Code=0; Msg=[IBM(DataDirect OEM)][ODBC SQL Server Wire Protocol driver]The server does not support SSL
Here is my ODBC configuration file:
INI
Driver=/opt/IBM/InformationServer/Server/branded_odbc/lib/VMsqls00.so
Description=DataDirect SQL Server Native Wire Protocol
AlternateServers=
AlwaysReportTriggerResults=0
AnsiNPW=1
ApplicationName=
ApplicationUsingThreads=1
AuthenticationMethod=1
BulkBinaryThreshold=32
BulkCharacterThreshold=-1
BulkLoadBatchSize=1024
BulkLoadOptions=2
ConnectionReset=0
ConnectionRetryCount=0
ConnectionRetryDelay=3
CipherList=DEFAULT:!RC4
Database=DIFFCAISSE1
EnableBulkLoad=0
EnableQuotedIdentifiers=0
EncryptionMethod=1
FailoverGranularity=0
FailoverMode=0
FailoverPreconnect=0
FetchTSWTZasTimestamp=0
FetchTWFSasTime=1
GSSClient=native
HostName=myhostname.example.com
HostNameInCertificate=
InitializationString=
Language=
LoadBalanceTimeout=0
LoadBalancing=0
LoginTimeout=15
LogonID=
MaxPoolSize=100
MinPoolSize=0
PacketSize=-1
Password=
Pooling=0
PortNumber=1433
QueryTimeout=0
ReportCodePageConversionErrors=0
SnapshotSerializable=0
TrustStore=
TrustStorePassword=
ValidateServerCertificate=1
WorkStationID=
XML Describe Type=-10
Why is the driver complaining that the server does not support SSL?

Resources