In the Maven project. When I first set up XAMPP and MySQL work very well. But inside NetBeans I can't connect to the MySQL and can't create a connect to the mysql-connector-java-8.0.20.zip or mysql-connector-java-8.0.20.jar.
driver="com.mysql.cj.jdbc.Driver" and url="jdbc:mysql://localhost:3306/mysql"
When I going to add new connection to MySQL it display error message,
Cannot establish a connection to jdbc:mysql://localhost:3306/mysql using com.mysql.cj.jdbc.Driver (The server time zone value 'unknown' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver
"The server time zone value 'unknown' is unrecognized or represents more than one-time zone"
This is a common error in MySQL to fix this error.
1)Create a new connection to MySQL
2)Connect JDBC driver to using mysql-connector-java-8.0.20.jar
3)In JDBC URL add server time zone as follows make sure your database name is mysql otherwise change the database name to your database name.
jdbc:mysql://localhost:3306/mysql?serverTimezone=UTC
NB:-If you want you can add server time zone as a connection property
set property as serverTimezone and value as UTC.
If this didn't work use MariaDb driver to connect MySQL
1)Create a new connection
2)Add mariadb-java-client-2.6.0 to the connection
3)In JDBC URL add as follows and you don't want to worry about server time zone when you use MariaDB
jdbc:mariadb://localhost:3306/mysql
It looks like you're running on windows but the solution for me involved customizing the mysql driver.
On the netbeans services tab open the drivers folder right-click the mysql connector/driver and then cutomize. Locate your driver on your system and add it to the class then click ok. Worked for me on ubuntu
Related
I'm setting up a JMeter Connection to Phoenix using its JDBC Connection Configuration but it wont connect due to some jars and connection problem. I have tried configuring all of the compatible jars and configure the connection but it won't work either.
I've added Phoenix Jar to Classpath in Test Plan Setting.
The JDBC connection setting are as below:
Database Url: jdbc:phoenix://ip:port:/hbase-unsecure/schema_name
Driver Class: org.apache.phoenix.jdbc.PhoenixDriver
After configuring the phoenix database all i want to do is to do some simple query like SELECT * FROM table_name
Using MySQL Connection was successful and it shows me the data inside the database. However using this Phoenix Configuration, it won't even connect to the database and I am getting various error such as
Cannot create JDBC driver of class 'org.apache.phoenix.jdbc.PhoenixDriver' for connect URL
or
Couldn't established connection
or
java.lang.NoClassDefFoungError: Could not initialize class org.apache.phoenix.jdbc.PhoenixDriver
I got it resolved. turns out the driver for phoenix (phoenix-4.7.0.2.6.1.0-129-client) is suitable for JMeter version 2.9.
And in order the phoenix driver to work in JMeter, use phoenix-4.7.0.2.6.4.0-91-client, not phoenix-4.7.0.2.6.1.0-129-client.
and if you have service mapping enabled problem, extract your jar, find hbase-default file, and add another property for service mapping enabled = true.
I was connecting to Sql Server 2008 & 2008+ via Java program with
Java 8
Sql jdbc microsoft driver 4.1
Connection string: DriverManager.getConnection("jdbc:sqlserver://<Ip>;instance=MSSQLSERVER;domain=<domain>;IntegratedSecurity=true;ssl=request;", "administrator", "password");
I was able to connect successfully.
However when I enabled Force encryption to true in the sql server via sql server configuration manager.
I started getting following error.
com.microsoft.sqlserver.jdbc.SQLServerException: An existing connection was forcibly closed by the remote host ClientConnectionId:xxxx
FYI:
I have already tried adding below parameters in connection string.
ssl=request
ssl=require
encrypt=true
trustServerCertificate=true
Also I have tried upgrading the driver to 4.2 & mssql driver 7.0
Tried jtds driver as well
Point to be noted: I am able to connect to instance via ssms
EDIT 1
- Another important point - It's happening only for windows authentication (enabled via IntegratedSecurity=true; in connection string).
So this case is happening only when Force encryption is set to true and we try to connect in windows authentication mode.
#Vivien #MarkRotteveel Thanks for your answers which gave me directions.
It turned out that sql server with version less then 11.0 were having troubles and various improvements were done as part of 11.0 version of sql server which rectified errors of windows authentication + encrypted connections connectivity.
So Sql server 2012 and above will support windows authentication with TLSv1.2, windows authentication along with encrypted connections seamlessly.
Now I am using
Java 8
Sql server driver 4.2
Windows 10
No extra parameters in connection string.
Just for reference: Found on Microsoft website.
It's unclear from your original question wether you have already done this, but if not, try setting both at the same time: encrypt=true;trustServerCertificate=true
Also, what do the SQL Server logs say?
I think Mark Rotteveel has right.
You need to check your version of both Java and SQL Server 2008.
TLS 1.2 has been enable by default in Java 8 since the u122, and appear in SQL Server 2008 only in the service pack 4 (version 10.0.6547.0, select ##VERSION; for check it)
If you don't meet the requierment, you have to choose between update the server or downgrade your jdk.
Perhaps their is an option in the JDK to retrieve the behavior prior to the update 122, but if it's the case, I don't know it.
And, for information, the mssql-jdbc driver has stop the support of SQL Server 2008 after the version 6.2.
I want to be able to connect to a SQL Server using jdbc and windows authentication.
I saw some answers on the internet saying i should add the following property to the connection string:
integratedSecurity=true;
And also add
sqljdbc_auth.dll
To the java path.
But this, as far as i understand applies only when i'm connecting from a Windows machine.
When i try this on a Linux machine i get:
java.sql.SQLException: This driver is not configured for integrated authentication
My question is how do I do it from a Linux machine.
Thanks
Well, eventually I answer my own question:
This is not possible to use Windows authentication from a linux machine using the Microsoft JDBC driver.
This is possible using the jTDS JDBC driver using the following connection string:
jdbc:jtds:sqlserver://host:port;databaseName=dbname;domain=domainName;useNTLMv2=true;
Thank you all for all the comments
TL;DR
It is not possible to use native Windows Authentication for JDBC connections to MSSQL from a JVM running on Linux.
This MSDN article explains the authentiation methods with JDBC on Linux, potential errors, and available options:
https://blogs.msdn.microsoft.com/psssql/2015/01/09/jdbc-this-driver-is-not-configured-for-integrated-authentication/
...in the JDBC 4.0 driver, you can use the authenticationScheme
connection property to indicate how you want to use Kerberos to
connect to SQL. There are two settings here.
NativeAuthentication (default) – This uses the sqljdbc_auth.dll and is specific to the Windows platform. This was the only option
prior to the JDBC 4.0 driver.
JavaKerberos – Makes use of the Java API’s to invoke kerberos and does not rely on the Windows Platform. This is java specific and not
bound to the underlying operating system, so this can be used on both
Windows and Linux platforms.
...
The following document outlines how to use Kerberos with the JDBC
Driver and walks through what is needed to get JavaKerberos working
properly.
Using Kerberos Integrated Authentication to Connect to SQL Server
http://msdn.microsoft.com/en-us/library/gg558122%28v=sql.110%29.aspx
For those who are using DBeaver the way to connect to the SQL Server Database is:
In order to connect to the SQL Server from Linux Debian using DBeaver
1.- Select SQL Server jTDS driver
2.- Enter the connection information
3.- Go to Driver Properties tab and add the domain, user, password
Just as a note, in some post I found that they needed to change the property USENTLMV2 to TRUE but it worked for me either by putting the USERTLNMV2 in true or false.
A problem that I found was that when I was trying to connect to the database using my user and password the next error was thrown:
Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.
This error was thrown because of my user was about to expire. I tried with another AD user and it could connect.
I know this is kind of an older topic but in case Google sends people here:
There are two main JDBC drivers for SQL Server. One is from Microsoft and the other from jTDS. jTDS can, amazingly, connect using Windows auth (NTLM) from other platforms, including Linux, as described here: http://jtds.sourceforge.net/faq.html#windowsAuth. It can, of course, also use SQL-authenticated logins. SQL-authenticated logins are no harder to use from any OS than any other, so don't forget about those an option.
The version provided by Microsoft is the one from which #mjn provided a quote from the documentation. It is able to connect using Windows authentication by specifying integratedSecurity=true, authenticationScheme=javaKerberos, and authentication=NotSpecified.
It is tricky to get this working even if you don't go out of your way to find more confusion, so always keep in mind which driver you are using - and tell us in these posts so that you can get more specific help.
This JDBC URL is validated to work with latest Microsoft SQL Server JDBC driver:
jdbc:sqlserver://[server]:[port];database=[db\;trustServerCertificate=true;integratedSecurity=true;user=[user without domain];password=[pw];authenticationScheme=NTLM;domain=[domain];authentication=NotSpecified
Example:
jdbc:sqlserver://mysql.myorg.com:1433;database=mydb;trustServerCertificate=true;integratedSecurity=true;user=myuser;password=mypwd;authenticationScheme=NTLM;domain=ad.myorg.com;authentication=NotSpecified
I was able to connect to a SQL Server 2016 Data Mart and JDBC connection Microsoft JDBC Driver using Windows Authentication using the following script on a Ubuntu Linux Docker Image running on Windows 10.
# initializes spark session
from pyspark.sql import SparkSession
spark = SparkSession\
.builder\
.master('local[*]')\
.appName('FDM')\
.config("spark.driver.extraClassPath","pyspark_jars/*")\
.config('spark.executor.memory', '4g')\
.config('spark.driver.memory', '16g')\
.config('spark.executor.cores', '4')\
.getOrCreate()
jdbc_url = '''jdbc:sqlserver://SERVER;databaseName=DBNAME;trustServerCertificate=true;integratedSecurity=true;user=USERID;password=PASSWORD;authenticationScheme=NTLM;domain=US;authentication=NotSpecified'''
spark_df = spark.read\
.format("jdbc")\
.option("url", jdbc_url)\
.option("driver","com.microsoft.sqlserver.jdbc.SQLServerDriver")\
.option("query", 'select top(1000) * from SCHEMA.TABLE')\
.option("fetchsize", 100000)\
.load()
spark_df.write.csv('TEST.csv', mode = "overwrite", header=True)
In admin properties, the paths are correct but, this error always appears whenever I try to connect to MySQL server from NetBeans.
Unable to connect to the MySQl server:
org.netbeans.api.db.explorer.DatabaseException:Cannot establish a connection to jdbc:mysql://localhost:3306 for user root"
You need to install Download Connector/J (This is the official JDBC driver for MySQL.)
Official Download Page: http://dev.mysql.com/downloads/connector/j/
I have installed DB2 Express-C 9.7.5. It was installed on a Windows 7 (64-bit) machine and I created a database, TESTXA. The connection mechanism used in my application is:
Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:db2://ABCCOMPUTER:50000/TESTXA", db2UserName, db2PassWord);
The connection successfully created on ABCCOMPUTER with the above Java code. But when I use the same Java code to create a DB2 connection from another system over LAN, for example, XYZCOMPUTER (Windows 7 machine) with the same db2UserName/db2PassWord, throws an exception:
com.ibm.db2.jcc.am.io: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=USER.XA4APP, DRIVER=3.57.82
Which indicates "Connection authorization failure occurred. Reason: User ID or Password invalid."
In my application, I need to create a database in DB2 which can be accessed from other systems on a LAN. What should be looked into on XYZCOMPUTER to resolve this issue?
(FYI: This is no issue of DB2 database sharing in Windows XP machines. The above mechanism works properly.)
This should be no issue of Java JDBC. It must be the case of a Windows 7 security issue because the DB2 type 4 driver uses the same format of the connection string whether it's a case of your own system or a remote system. You can try to run your application/tool as 'Run as Administrator'.