Why snowflake jdbc throws [XX000][200001] error - jdbc

I try to make connections on snowflake via datagrip and DBeaver. Test connections successfully connects on both, but it does not load the schemas and throws an error like this:
[XX000][200001] JDBC driver internal error: exception creating result
java.lang.IllegalArgumentException: No enum constant
net.snowflake.client.jdbc.SnowflakeType.TİMESTAMP_LTZ at
java.base/java.lang.Enum.valueOf(Enum.java:240).
Any solutions or faced with anyone else?

This is the common bug in java programs, in your case in JDBC driver.
That caused by converting string to upper case without specifying locale, which defaults to system, which is Turkish in your case, causing "i".toUpperCase() to be "İ".
To workaround that you could specify locale for process. In DataGrip, you can go to advanced tab of the data source settings and put -Duser.country=US -Duser.language=en to VM Options

Related

Spring Boot - Unable to connect Azure MySQL database

I am new in connecting azure MySQL database from Spring boot application.
Below is the snippet mentioned in application.properties
spring.datasource.url=jdbc:mysql://XXXX.mysql.database.azure.com:3306/MyDbName
spring.datasource.username= ******
spring.datasource.password= ******
I have faced the following exception
org.springframework.jdbc.support.MetaDataAccessException: Could not get Connection for extracting meta data; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Unknown system variable 'query_cache_size'
I have googled and somewhere it was mentioned that it is required to update the version of MySQLConnector to 8.0.13
Please help me find the solution.
Based on your exception , its not because of Azure mysql. Its because of system variable 'query_cache_size'. refer : java.sql.SQLException: Unknown system variable 'query_cache_size'
I too have met this bundle of joy on azure MySQL. As dvo mentions it places this variable in when it thinks it is under version 8.0.3.
From com.mysql.cj.NativeSession.java...
if (!versionMeetsMinimum(8, 0, 3)) {
queryBuf.append(", ##query_cache_size AS query_cache_size");
queryBuf.append(", ##query_cache_type AS query_cache_type");
}
But as my Azure MySQL version is 8.0.15 which matches my driver version then I suspect whilst the database may well be version 8 part of the stack the driver deals with is not.
Edit:
From https://learn.microsoft.com/en-us/azure/mysql/concepts-limits
Current known issues
MySQL server instance displays the wrong server version after connection is established. To get the correct server instance engine version, use the select version(); command.
So I'm guessing that this is the problem and as it stands Azure MySQL 8 will not work with the java mysql connector.
I'll probably look at building the connector myself and hard coding in the version number to 8.0.15. What joy.
Edit Edit:
Modified ServerVersion.java parseVersion(…) to return
return new ServerVersion(8, 0, 15);
Which works around the problem enough for me to carry on with my work.
It's a problem Microsoft should be fixing ASAP on their side.

Error connecting SQL Workbench/J to Amazon Athena

I've been having a lot of problems connecting SQL Workbench/J to Amazon Athena through the JDBC connector. Also, the instructions seem to vary between these two help resources:
http://docs.aws.amazon.com/athena/latest/ug/athena-sql-workbench.html
https://s3.amazonaws.com/athena-downloads/drivers/JDBC/docs/Simba+Athena+JDBC+Driver+Install+and+Configuration+Guide.pdf
Here's the error message:
[Simba]JDBC Connection Refused: [Simba]JDBC Required Connection Key(s): AwsRegion; [Simba]JDBC Optional Connection Key(s): AwsCredentialsProviderArguments, AwsCredentialsProviderClass, BinaryColumnLength, ComplexTypeColumnLength, ConnectTimeout, MaxCatalogNameLength, MaxColumnNameLength, MaxErrorRetry, MaxSchemaNameLength, MaxTableNameLength, ProxyHost, ProxyPort, ProxyPWD, ProxyUID, S3OutputEncOption, Schema, SocketTimeout, StringColumnLength, UseAwsLogger
The documentation at #1 is deprecated, as you might gather from the different filenames in the two guides. Amazon hasn't fully cleaned up their docs, since switching from their homegrown JDBC driver to the driver they've OEMed from Simba.
You did not provide the JDBC URL you're using, so I cannot provide a specific correction, but the error message you got seems pretty clear -- you apparently didn't build your JDBC URL correctly. It's missing the mandatory AwsRegion setting.
Note the URL syntax from the PDF guide for the JDBC driver you're using --
jdbc:awsathena://AwsRegion=[Region];UID=[AccessKey];PWD=[SecretKey];S3OutputLocation=[Output];[Property1]=[Value1];[Property2]=[Value2];...
Here is how I have done it
Make sure you have Java8 installed
Download the latest Athena jar
Make a new driver in sql work bench
Add the jdbc connection and username/password
location would be location you logged into the account and what setting is in the url Thus my url is: jdbc:awsathena://athena.us-east-2.amazonaws.com:443
Username= Access Key Id; Password= Secret Access Key
Then do not forget the extended properties! set the s3_staging_dir to the bucket you created for your Athena results, or you will need to look and see what the default bucket is created. This bucket must start with aws-athena-query-results
Update version 2.07
Bucket is now S3OutputLocation not s3_staging_dir:

List of Weblogic Error Codes

Context
I have been debugging an Oracle Weblogic Server 10.3.0.0 JDBC Connection which is logging the error code:
BEA-001112
After some searching around I found a bit of an explanation here:
http://docs.oracle.com/cd/E21764_01/core.1111/e10106/dbac.htm#BHCFFAJF
Although it does depend on the actual exception being thrown, I believe this means:
there was an error when testing a new connection in the JDBC Connection Pool before handing it off to be used by the application.
Question
Does anyone know of a list of Weblogic Error Codes that has a general description for the specific Error Code?
In Oracle portfolio WebLogic is a part of Oracle Fusion Middleware (OFMW). Thus the error code (or message) list is a part of OFMW documentation.
As the links a quite difficult to find for uninitiated here's direct links to a few different releases.
WebLogic 10.3.3
WebLogic 10.3.6
WebLogic 12.1.3
They are not much descriptive, but hopefully can give you at least an introduction. You can also index them by subsystem. Clicking on a message (or message range) will bring up the details.
Cause: The specified data source connection pool has been configured with one or
more attributes to test the pool connections. One of those test attempts failed. The
associated error is printed.
Action: Check the associated error to see what the problem is and correct it.
Normally, this indicates that a connection was lost to the database (the database is
down). This needs to be corrected by the database administrator.

ORA-00604 ORA-12705

I am having this error in my j2ee web application.
java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-12705: Cannot access NLS data files or invalid environment specified
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:283)
oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:278)
oracle.jdbc.driver.T4CTTIoauthenticate.receiveOauth(T4CTTIoauthenticate.java:785)
oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:376)
oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:441)
oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:839)
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1353)
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1353)
This project works in my colleagues' PCs... I mean this project works for them but when I asked for their project folder and imported it on my eclipse, when i run it i meet this error. The jar files are already packaged with the project folder.
I also created a simple j2ee project using hibernate but I had the same error.
I tried to ping the DB server and browse it using PL/SQL developer and I don't have any problem with it
Try following:
Check that NLS_LANG setting is correct. On windows it is in registry under \HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE.
Check that Oracle client software is correctly installed.
Check if there are multiple Oracle homes on that computer. In that case, find active one and check if it works.
Test with SQL*Plus if there is one installed. Sql Developer works because it has its own client installation.
Edit:
Regarding drivers, check this site: Oracle Instant Client. There you will find documentation on minimum drivers installation needed for JDBC access to Oracle. I don't know much about that because I use .Net.
Edit 2:
See this question: NLS_LANG setting for JDBC thin driver. There is same error as you have and problem was that default locale for NLS LANG was not defined. Quote:
The NLS_LANG settings are derived from the java.util.Locale . Therefore, you will need to make a call similar to this before connecting:
Locale.setDefault(Locale.<your locale here>);
I figured out that that you could pass that two params to your Java app to resolve the issue:
-Duser.country=en -Duser.language=en
You could configure the values at environment variable level as well (depends from your OS).
I had the same problem. The solution was to add the country and the language to sqldeveloper.conf
Please open the file:
\sqldeveloper\sqldeveloper\bin\sqldeveloper.conf
And add the following:
AddVMOption -Duser.language=en
AddVMOption -Duser.region=us
The above does the trick.
Reference: http://forum.oradba.net/showthread.php?t=423&langid=1
For Windows env, you need to change the System Locale and System Format to English/US.
How to change system locale?
I found solution, I just change the regional and language in my OS (windows 7), make sure it matches with the oracle regional and language.
Oracle JDBC driver implicitly executes following statement after opening new connection:
ALTER SESSION SET NLS_LANGUAGE='language' NLS_TERRITORY='territory'
In our case we had problems with Oracle XE 11g and default language/territory mappings embedded into JDBC driver: 'ru' locale was mapped to 'CIS' territory which is supported only by Oracle EE, but Oracle XE had 'RUSSIA' territory only.
Here is the way we fixed this:
-Doracle.jdbc.territoryMap="ru=RUSSIA;RU=RUSSIA"
There is option for NLS_LANGUAGE(we had no problems with defaults):
-Doracle.jdbc.languageMap="ru=RUSSIAN;RU=RUSSIAN"
Fixed: constant ru=RUSSIAN taken from class oracle.sql.converter.CharacterSetMetaData of java jdbc driver.
If you are compiling with intelljIDE I advise you add following options in VMoptions found in configurations model
AddVMOption -Duser.region=us.
First execute query:
select userenv('LANGUAGE') from dual;`
This will give oracle regional and language. Change the regional and language in OS, both should match.
check the JAVA_HOME system variable and verify that it is the same version you are using in your projects and programs
Changing the region settings and language of my machine helped to get away with this.
I changed region to United States and English (United States) as language.
If you are running a spring application just add Locale.setDefault(Locale.ENGLISH); at main class.
public static void main(String[] args) throws Exception
{
Locale.setDefault(Locale.ENGLISH);
SpringApplication.run(ApplicationName.class, args);
}

NLS_LANG setting for JDBC thin driver?

I am using the thin Oracle JDBC driver ver 10.2.0 (ojdbc14.jar). I would like to configure its NLS_LANG setting manually. Is there a way?
Currently it fetches this setting from the VM variable user.language (which is set automatically by setting the current locale, or on startup from the system environment).
This is a problem when the users switch the application locale to a one that is unsupported by the Oracle JDBC driver (e.g. mk_MK). In this case, the next time I fetch a connection I get the following exception:
ORA-00604: error occurred at recursive SQL level 1
ORA-12705: Cannot access NLS data files or invalid environment specified
I can change the locale on the fly just before I fetch the connection and switch back to the user's selected one back and forth, but this seems unelegant and unefficient.
See also: https://serverfault.com/questions/63216/ora-12705-cannot-access-nls-data-files-or-invalid-environment-specified/64536
For me the best response was by FoxyBOA to invoke java app with:
-Duser.country=en -Duser.language=en
The NLS_LANG settings are derived from the java.util.Locale . Therefore, you will need to make a call similar to this before connecting:
Locale.setDefault(Locale.<your locale here>);
I was fighting the same problem and found out that thin jdbc Oracle drivers do not require NLS_LANG or system locale to be specified. But when you connect to non-english databases you are to have orai18n.jar in the classpath.
from Oracle® Database JDBC Developer’s Guide and Reference
Providing Globalization Support
The basic Java Archive (JAR) files,
ojdbc5.jar and ojdbc6.jar, contain all
the necessary classes to provide
complete globalization support for:
Oracle character sets for CHAR,
VARCHAR, LONGVARCHAR, or CLOB data
that is not being retrieved or
inserted as a data member of an Oracle
object or collection type.
CHAR or
VARCHAR data members of object and
collection for the character sets
US7ASCII, WE8DEC, WE8ISO8859P1,
WE8MSWIN1252, and UTF8.
To use any other character sets in
CHAR or VARCHAR data members of
objects or collections, you must
include orai18n.jar in the CLASSPATH
environment variable of your
application.
Invoking java with the following works for me :
-Duser.country=us -Duser.language=en
if "en" for country also causes ORA-12705.
You should use the old Oracle 9.2 JDBC driver that is fully compatible and certified with Oracle 10g. The old driver does not use ALTER SESSION SET NLS_LANGUAGE commands.

Resources