I'm new to Sybase database and trying to connect to Sybase using Java JDBC connection and sajdbc4.jar, but getting an error:
java.sql.SQLException: [Sybase][JDBC Driver][SQL Anywhere]Database server not found
Here is my connection string:
jdbc:sqlanywhere:uid=user;pwd=xxxx;eng=xx_sql;database=dummy;links=tcpip(host=xx.xx.xx.xx)
Firstly ensure that you point the database file to the SQL Anywhere Server and restart the server.
Secondly analyze your database logs, check if you can trace the connectivity with SQL PLUS or any other database connectivity tools.
If you are able to solve it, then that's fine or else I suspect that the issue to be related to this issue on SO here
As per this question, please make the following changes and I guess that the issue should be resolved
jdbc:sqlanywhere:Server=yourservername;uid=user;pwd=xxxx;port=2638;eng=xx_sql;database=dummy;links=tcpip(port=2638)
It is mandatory to mention the use of TCP/IP protocol to yourJDBC driver through the connection string above!
Hope this helps!
Related
I fail to establish a connection to a MySql database on an external server when I use the mysql-connector-java version 8.0.11+ (I was currently testing with 8.0.25). However I am able to create a connection when I use the older MySql connector mysql-connector-java version 5.1.49.
The version of the MySql Database is "8.0.25-15"
The code fails on the first line:
try (Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
{...}
Since I can connect though mysql-connector-java version 5.1.49, I first thought I could solve this problem by adding parameters to the DB_URL. I have experimented with a lot of parameters, but no luck:
useSSL=false
serverTimezone=GMT
useUnicode=true
characterEncoding=utf-8
passwordCharacterEncoding=utf-8
connectionCollation=utf8mb4_bin
autoReconnect=true
failOverReadOnly=false
maxReconnects=10
cacheServerConfiguration=false
The error I always receive is:
java.sql.SQLNonTransientConnectionException: Could not create connection to database server.
Caused by: java.lang.NullPointerException: Cannot invoke "String.toUpperCase(java.util.Locale)" because "javaEncoding" is null
at com.mysql.cj.CharsetMapping.getMysqlCharsetForJavaEncoding(CharsetMapping.java:552)
at com.mysql.cj.CharsetMapping.getCollationIndexForJavaEncoding(CharsetMapping.java:585)
at com.mysql.cj.protocol.a.NativeServerSession.configureCharacterSets(NativeServerSession.java:452)
at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1329)
at com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:866)
A month ago, I did not have this problem, so I suspect the cause is a change in the database (I am not tbe database Administrator).
When I debug, the error seems to be caused because the program requests the "character_set_system" variable from MySql, which is"utf8mb3" (instead "utf8" or "utf8mb4").
I suspect that changing the database variable "utf8mb3" to "utf8" might solve this problem? But I am not certain and I cannot simply change this value because the database is hosted by an external company. I have typed "Show Variables" and "Show Global Variables" in a MySql editor for your information:
A screenshot of the DB variables concerning language.
Alternatively I would like to tell java to ignore "character_set_system". It seems that Java first looks for "local.character_set_results", but this variable returns null despite that "character_set_results" is defined in the database.
I hope someone can help me with this problem.
Kind Regards
Steven
This is error stack trace i am getting...
Could not connect to mydb.
Error creating SQL Model Connection connection to mydb. (Error: oracle.jdbc.OracleDriver)
oracle.jdbc.OracleDriver
Error creating JDBC Connection connection to mydb. (Error: oracle.jdbc.OracleDriver)
oracle.jdbc.OracleDriver.
I am using oracle thin driver to connect to database..
SID: db
Host: localhost
Port number 1521
User name: system
Password:
Connection URL: jdbc:oraclethin:©lccalhost:1521:db
I can't even able to ping the database...
There is a typo in your connection URL. It says lccalhost instead of localhost. Try:
jdbc:oraclethin:©localhost:1521:db
Furthermore, your log says mydb instead of db as stated in your connection settings. So, this may be another possible cause of fault.
I think you are using xpress edition 11-g and if so then try changing the SID from db to xe and then it should work fine .
If you are using the standard edition then you must check with the odbc jars .
Try adding odbc6 jar
What is the correct method of connecting to a SQL Server database from Android using JDBC?
I am trying to connect to a SQL Server database from Android but cannot find any SQL Server examples. I found Jav_Rock's answer here for connecting to a MySQL database.
So I replaced his example getConnection() method with my own:
jdbc:sqlserver://xxxxxxxx.xxxx.xxxxx.xxxxxx:1433/dbname
However, I then get the error message:
com.microsoft.sqlserver.jdbc.SQLServerException: The port number 1433/dbname is not valid.
This suggests that the syntax does not support the database name included in the URL. Can anyone help me with the correct method of connecting to a SQL Server database via JDBC?
try this way
Connection connection=DriverManager.getConnection("jdbc:sqlserver://xxx.xxx.x.xxx;databaseName=databasename;integratedSecurity=true;");
I'm using jtds and I'm trying to connect my java application to a Microsoft SQL Server 2005. Below is my connection URL.
jdbc:jtds:sqlserver://10.0.158.176:1433/NitgenAccessManager;
instance=SQLEXPRESS; user=sa;password=password
I'm trying to do a remote connection (DB server is in a different computer).
Whenever I try to run the program I get the following error:
Cannot open database "NitgenAccessManager" requested by the login. The
login failed.
I'v read the different posts concerning this same problem and I've tried their suggested solutions but none worked.
Thanks for future help. :)
One of the following (assuming that you connecting as sa:
DB NitgenAccessManager does not exists
DB NitgenAccessManager is not online (suspect, recovery and so on)
I'm getting the following error when trying to connect to a Sql Server (2005) using JDBC:
unhandled token type: unknown token: 0x53
Any ideas anyone? I would have liked a more descriptive error too!!
Also, I've done the 'telnet servername 1433' test and can confirm that machine can create a TCP connection.
As an alternative to the MS dirver you could also try jTDS. I've had good experience with this driver on SQL Server 2000. The project page states it is also fit for SQL Server 2005.
Sounds like you're using an old driver for the pre-2005 SQL protocols. You need to use the new JDBC Driver for SQL 2005.
In the end, the cause of this problem was that we had mirroring turned on. So, to solve it without upgrading the driver we had to turn off database mirroring. But, since this is a kludge really, a better idea would be to use a better driver, i've marked that other answer as the solution.