Android - connect to mssql database by jdbc - java

I'm trying to connect to live mssql database directly but I got the erro
"07-26 16:27:25.407: W/System.err(7136): java.sql.SQLException: Charset 0x0404E00000/MS950 is not supported by the JVM."
Here is the sample program I used by just changing the address/name/pw of the database.
https://github.com/alkber/AndroidByExample/tree/master/AndroidMSSQL2008

This problem is due to the JVM installed on your server.
It's caused by a limited language-only package (like US/English-only package).
You have to change the JVM to resolve this problem.
Reinstallaing JVM with complete language package should resolve your issue.

You shouldn't use jdbc for best coding and performance. Try to webservices.

Related

SQL Java Data connection

I having difficulty sequencing the class path for the jars, url for Microsoft SQL Express 2019 into a java method. I haven’t been able to connect the drivers to open and execute sql file within java module, the new JDBC Requirements is causing a run error. This also occurwhen running on access. Can some provided a thorough explanations so I can think of what I might have coded in the connection url.

Io exception: Oracle Error ORA-12650 in Oracle Cloud

I have been using Oracle cloud PAAS linux server for my DB machine (Oracle 11g) and having linux application server where i can run all my Java applications.
Assume i have spring based web application which can connect cloud DB machine. I have tried to access the schema in Toad for oracle, it is working as expected but when i try to hit the DB for retrieving the data from application it gives below error.
java.sql.SQLException: Io exception: Oracle Error ORA-12650
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:420)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at GetConnection.main(GetConnection.java:35)
I have also tried to extend the service access from SID to service name in DB machine. Still give same error. Same code works fine in another cloud machine, which was set by us. But this cloud machine was done by oracle team and most of the things are by default.
Please share your suggestion to fix this issue.
This issue is because of Oracle DB machine encryption ENCRYPTION_SERVER settings. As i understood which is default and set it to enabled, when we set it to disabled or comment the line then application will work as expected. Below is the file name for reference,
Filename : sqlnet.ora (We have to disable ENCRYPTION_SERVER settings)
File Location : ../oracle/product/11.2.0/dbhome_1/network/admin
Hope this helps some one.!
It did not help me at all. Actually I followed your solution and I ended up having another error more critical and serious than the one trying to solve.
Let me explain. First of all the value "disabled" that you mentioned is not even an accepted value for this parameter. According to Oracle (Oracle Docs) these are the accepted values that anyone can use:
SQLNET.ENCRYPTION_SERVER
Purpose
To turn encryption on for the database server.
Default
accepted
Values
accepted: to enable the security service if required or requested by the other side.
rejected: to disable the security service, even if the required by the other side.
requested: to enable the security service if the other side allows it.
required: to enable the security service and disallow the connection if the other side is not enabled for the security service.
Example
SQLNET.ENCRYPTION_SERVER=accepted
In my case being a 12c Oracle Cloud database the default was set to "required" giving me the error "Io exception: Oracle Error ORA-12650" when trying to start my application.
Setting the parameter to "accepted" solved the issue and managed to start my application.
In case you still get the error you can also set the following parameter to accepted:
SQLNET.CRYPTO_CHECKSUM_SERVER = accepted
if you see that in your sqlnet.ora the value is set to "required".
Please have in mind that my application as well as my OCI setup are for testing purposes only and they are not intended to be used in production environment. Setting the value of SQLNET.ENCRYPTION_SERVER and SQLNET.CRYPTO_CHECKSUM_SERVER to "accepted" will significantly lower your Database's security making it vulnerable to any attacks from any application that has access to it. The best case scenario is to modify your application to use the ENCRYPTION as "required".
Downgrading the OJDBC jar to version7 also works - Replace higher version(ojdbc14.jar was the culprit in my case) with ojdbc7.jar in your dependency files

Error creating jtds connection

Using jtds 1.2.5 I have this error when I stablish a connection: "No message resource found for message property prop.sokeepalive"
At first, I was using 1.2.2 version but I have this error message. "Error getting jdbc connection: The USE database statement failed because the database collation Serbian_Latin_100_CI_AS is not recognized by older client drivers. Try upgrading the client operating system or applying a service update to the database client software, or use a different collation. See SQL Server Books Online for more information on changing collations."
As solution, I tried to use 1.2.5 version getting the error mentioned at the beggining.
I was looking for hints in jtds documentation, but I can not resolve the problem.
any ideas?
Thanks in advance.
Try running client JVM with -Duser.language=en -Duser.region=US -Duser.country=US options.
This would switch to everywhere-supported US locale.
Maybe this easy solution would be acceptable in your case.
At least, this would reveal if the problem is in lack of i18n messages resource bundle for current locale in jtds package, as I guess.
Update
Try to just copy jtds.jar/net/sourceforge/jtds/jdbc/Messages.properties and add it to classpath or right inside jtds.jar as net/sourceforge/jtds/jdbc/Messages_sr_RS.properties.
Some explaining links:
Message bundle choosing process
net.sourceforge.jtds.jdbc.Messages source
http://www.localeplanet.com/java/sr-RS/
Update 2
Message bundle choosing process should switch to default provided resource anyway.
My second guess is that Messages.properties of jtds package gets eclipsed by some unrelated file with the same name.
Check your classpath.
You should be able to debug net.sourceforge.jtds.jdbc.Messages in order to find what's happening on for sure.
I have tried other jtds versions. from 1.2.2 yo 1.3.1 (recompiled to java 1.6) and all of them has the same error.
"Error getting jdbc connection: The USE database statement failed because the database collation Serbian_Latin_100_CI_AS is not recognized by older client drivers. Try upgrading the client operating system or applying a service update to the database client software, or use a different collation. See SQL Server Books Online for more information on changing collations."
Perhaps jdts does not support this collation.

Listener refused the connection with the following error: ORA-12514

I am trying to connect to an Oracle Database using java and JDBC code. I can't do that because I get the error below:
java.sql.SQLException: Listener refused the connection with the
following error: ORA-12514, TNS:listener does not currently know of
service requested in connect descriptor
What is the reason for the error and how to fix it ?
PS-
Out of all the DBMS, Oracle express 11g seems to be the most complicated and difficult to use.
Is that really the case ?
Listener does not currently know of service requested in connect
descriptor
Self explainatory. You're requesting connection to a service or instance in a DB that the DB's listener does not know, so it says "I have no clue".
Check the way you installed your Oracle 11g express. Remember that the service name there is often "xe".
I resolve this issue by increasing RAM size of my Virtual machine because i installed oracle
in VM that require more memory. So this could be one reason for your problem.

Error while connecting to Oracle DSN using Java

I need to develop an application that connects to various DSN's using the Microsoft ODBC drivers. I have developed the application in Eclipse and it seems to work properly. The connection succeeds and I am able to view table data.
However when I export the project to a runnable jar file (using Eclipse) the functionality fails for Oracle. It is unable to establish connectivity with the Oracle connection string. It still works for SQL server but fails in case of Oracle. I'm unable to figure out the cause as the same ODBC drivers are being used for both Oracle and SQL-Server. More mystifying is that it runs properly on Eclipse. Since im using the ODBC drivers I don't believe the problem is because of an external jar file.
The driver is sun.jdbc.odbc.JdbcOdbcDriver and connection string is like jdbc:odbc:oratest;user=fell;password=pass.
I'm getting the following exception
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
Can you please help me figure what the problem might be?
Thanks in advance,
Fell
Create a System DSN.
java.sql.Connection cn;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=java.sql.DriverManager.getConnection("jdbc:odbc:dsn_name","user","pass");
Check the classpath in the eclipse project

Categories

Resources