Quantcast
Channel: MySQL Forums - Connector/J, JDBC and Java
Viewing all 884 articles
Browse latest View live

using MySQL Transactions with Connector/J (1 reply)

$
0
0
Hi,
in MySQL docs there is a note about my question


"Important

Many APIs used for writing MySQL client applications (such as JDBC) provide their own methods for starting transactions that can (and sometimes should) be used instead of sending a START TRANSACTION statement from the client. See Chapter 20, Connectors and APIs, or the documentation for your API, for more information."

I could not find any information in Connector/J docs about this specific feature.
I would use transaction in java but im not sure what will happen if I used both java and mysql transactions. Or should I use java (JDBC) transactions only?

Communication link failure (no replies)

$
0
0
Hi,
I am working with large data set. I have created 100 tables. each table has same schema (12 columns) and 10,000 rows.
There are 50 threads on each table that fires select * from table query .


I am using streaming resultset. i am closing connections, statements and resultset after using it. after running 40 - 50 min. it throws the exception:

com.mysql.jdbc.CommunicationsException: Communications link failure

Last packet sent to the server was 2217953 ms ago.
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2871)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3414)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:910)
at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1405)
at com.mysql.jdbc.RowDataDynamic.nextRecord(RowDataDynamic.java:413)
at com.mysql.jdbc.RowDataDynamic.next(RowDataDynamic.java:392)
at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7034)
at org.apache.commons.dbcp.DelegatingResultSet.next(DelegatingResultSet.java:169)

Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2428)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2938)
... 11 more

The same code works fine for lesser no of tables and threads.

i have set multiple timeout in my.ini file.

connect_timeout = 31536000
interactive_timeout = 31536000
wait_timeout = 31536000
net_write_timeout = 31536000

If anybody have any idea about it. Please guide me.
Thanks
Sukumar

jdbc + mysql (1 reply)

$
0
0
I am working on windows 7. mysql 5.2


I am getting the problem when i am trying to execute the connectivity of java with mysql.


how can i check whether mysql server is running or not?

i m using the software for database creation sqlyog

Where to put mysql jdbc driver on Solaris 10 to solve java.lang.ClassNotFoundException: com.mysql.jdbc.Driver (1 reply)

$
0
0
I need to setup mysql + java on my latest project. After install mysql community server v5.1.50, instead of using Solaris 10 bundled v4.0.31 (it's another topic), I tried to kick of the java application, unfortunately, got error "java.lang.ClassNotFoundException: com.mysql.jdbc.Driver". I downloaded jdbc connector jar file from sun, put on to application local directory, and set CLASSPATH environment, failed. Then, specified '-classpath' option onto java command line, also failed.

After tons of trails, finally, found the solution to fix the exception.
put jdbc connector jar file on to java ext lib directory, on Solaris 10, where is:
/usr/java/jre/lib/ext

Hopefully, this clue helps you.

Mysql connectivity problems (1 reply)

$
0
0
I want connect jsp page with mysql and getting this error in connection page get me out of this problem.

My connection Jsp page Like this

<%@ page import="java.sql.*"%>
<%!
Connection cn=null;
Statement st=null;
%>
<%
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/dhyuti", "root", "123456");
st=cn.createStatement();
out.println("Registration successfully completed...");


%>


The error am getting is.

org.apache.jasper.JasperException: Exception in JSP: /dhyuti technologies/getcon.jsp:7

Statement st=null;
%>
<%
Class.forName("com.mysql.jdbc.Driver");
cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/dhyuti", "root", "123456");
st=cn.createStatement();
out.println("Registration successfully completed...");

com.mysql.jdbc.LocalizedErrorMessages (no replies)

$
0
0
I'm coding JAVA with JBuilder 2005 on SLES10 and use mysql-connector-java5.1.7.
Within ID I cann succesfully connect to my MySQL-DB, but when executing the jar-Archive, generated be JBUILDER, on the same machine, I get the following error:
# java -jar AFC_Client-V1.2.jar 192.168.100.98 192.168.100.98 MySQL afc /localAdBase /tmp /home/seliger
RMIProdServerIP=192.168.100.98
ProdDBIP=192.168.100.98
DB_VENDOR=MySQL
DB_NAME=afc
localAdBase /localAdBase
localTempDir=/tmp
AFC_InDesign_Com_path=/home/seliger
RMIProdServerIP 192.168.100.98
looking up 192.168.100.98
AFC-ProdServer successfully looked up on 192.168.100.98
AFC-ProdServer on 192.168.100.98 answered on ReplyRequest: 'here I am'
lookup returned 0
going to get connection for mysql
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.mysql.jdbc.Util.stackTraceToString(Util.java:350)
at com.mysql.jdbc.Util.<clinit>(Util.java:115)
at com.mysql.jdbc.NonRegisteringDriver.parseURL(NonRegisteringDriver.java:672)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:277)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:193)
at processappl.DBFunctions.connect_MYSQL_DB(DBFunctions.java:233)
at processappl.DBFunctions.connectDB(DBFunctions.java:187)
at processappl.processApplication.main(processApplication.java:699)
Caused by: java.lang.RuntimeException: Can't load resource bundle due to underlying exception java.util.MissingResourceException: Can't find bundle for base name com.mysql.jdbc.LocalizedErrorMessages, locale de_DE
at com.mysql.jdbc.Messages.<clinit>(Messages.java:60)
... 9 more
Caused by: java.util.MissingResourceException: Can't find bundle for base name com.mysql.jdbc.LocalizedErrorMessages, locale de_DE
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:838)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:728)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:551)
at com.mysql.jdbc.Messages.<clinit>(Messages.java:58)
... 9 more
The used Connection is from java.sql.
A class com.mysql.jdbc.LocalizedErrorMessages itself is not contained within the generated jar, but another file LocalizedErrorMessages.properties, contained in the mysql-connector-java5.1.7.jar doses not appear within the generated byJBuilder Archive-jar as well as several other class-files.
What is the reason for that fact and how to avoid it?

Regards
Jochen Seliger

where price=7.99; in the select caluse is not working (1 reply)

$
0
0
Hi,

I have been trying to use the following command in the mysql> command prompt like this:

mysql> select column1, column2 from TableA where price=7.99;

It gives me the following response:

Empty set <0.00 sec>

Is it possible the mysql doesn't have = operator, but it works with the char variables just like it does in SQL.
Please let me know what's going on here.

Thanks,

cK

How to store special character (Mathamatical symbols) in Mysql. (no replies)

$
0
0
Hi,
I'm using mysql server 5.1. Also I'm using JSP, Spring(MVC) and hibernate in my application for windows platform (Window XP and later version).
I want to store special charaters (Mathamatical operators and scientific notation charater) like ∅∆Β ∞ √ ∑ ≥ ≠ ≤ ≈ μ ϒ ∏. But these chars are stored as ? in the DB.
Till now I've tried following.
1. I've used connection url like
jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf-8
2. I've tried modifing my table an corresponding column like
a. ALTER TABLE `test`.`mytable` COLLATE = utf8_general_ci ; and
b. ALTER TABLE `test`.`mytable` COLLATE = utf8_general_ci ;

Can anybody please help me to let me know what all changes I need to do to store and retrive these chars from DB.
-Thanks in advance
Mohan

How to store special character (Mathamatical symbols) in Mysql. (-1 replies)

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown character set: 'utf8mb4' (no replies)

$
0
0
When i running a java program, a error "com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown character set: 'utf8mb4'" has been release. How can i fix this error?
I use mysql 6.0.4-alpha and mysql-connector-java-5.1.13.
Is mysql-connector-java-5.1.13 can not support mysql 6.0.4-alpha?Only for mysql 5.0?

ConnectorJ Licensing (no replies)

$
0
0
Hi,

We have an application that is built and used by customers with a Software-As-A-Service model. It is not packaged and distributed as a binary. We want to comply with the MySQL license, but do not want to make our product open source.

What is the procedure for complying with the license terms so that we do not have to make our product open source but still make it available with the SAAS model.

Thank you for your time.

Cheers!

Problem with UTF-8 encoding + JDBC (no replies)

$
0
0
I'm using MySQL Server versino 5.1.36-community and the mysql-connector-java-5.1.7-bin.jar

Here's my create table statement

STATE_PROVINCE | CREATE TABLE `state_province` (
`NAME` varchar(50) NOT NULL,
`ISO_CODE` char(2) NOT NULL,
`COUNTRY` char(2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8

From the command line, I get correct output

mysql> SELECT * FROM STATE_PROVINCE WHERE COUNTRY = 'DE';
+------------------------+----------+---------+
| NAME | ISO_CODE | COUNTRY |
+------------------------+----------+---------+
| Baden-Württemberg | BW | DE |
| Bayern | BY | DE |
| Berlin | BE | DE |
| Brandenburg | BB | DE |
| Bremen | HB | DE |
| Hamburg | HH | DE |
| Hessen | HE | DE |
| Mecklenburg-Vorpommern | MV | DE |
| Niedersachsen | NI | DE |
| Nordrhein-Westfalen | NW | DE |
| Rheinland-Pfalz | RP | DE |
| Saarland | SL | DE |
| Sachsen | SN | DE |
| Sachsen-Anhalt | ST | DE |
| Schleswig-Holstein | SH | DE |
| Thüringen | TH | DE |
+------------------------+----------+---------+


From java, I am using the following code:

Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql:///tech3?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8";
Connection con= DriverManager.getConnection(url,"username","password");

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("SELECT NAME FROM STATE_PROVINCE WHERE COUNTRY = 'DE'");
while(rs.next()) {
System.out.println(rs.getString(1));
}

And it's printing the following to the console:

Baden-W?rttemberg
Bayern
Berlin
Brandenburg
Bremen
Hamburg
Hessen
Mecklenburg-Vorpommern
Niedersachsen
Nordrhein-Westfalen
Rheinland-Pfalz
Saarland
Sachsen
Sachsen-Anhalt
Schleswig-Holstein
Th?ringen

How can I get the ü to display in the console instead of the question marks? The UTF-8 encoding properties don't seem to be working correctly. Any ideas are appreciated.

Wrong (no more existing query) executes (no replies)

$
0
0
So my problem is just as follows:

I have created a simple method with one parameter containing information i want to write to an database.

I have two queries in my method.

the first query contained some syntax errors, which i corrected. After that the query gave me the same error evertime i tried to execute the code. Just for testing i tried some variation with no result and decided to delete that query trying to test the other one. that's when i noticed that the error given to me was still the same reffering to the same line where the query i just deleted HAD BEEN.

So i don't really know what to do. It's kind of frustrating...

any help would be greatly appreciated

regards pascal

edit: i debugged the whole application and in the method i described above not only the query, but even the deleted java-code is executed. i can see the variables changing...

New parameters in Stored Procedure + Java Servlets (no replies)

$
0
0
Hi.

I have a Java Servlet which calls a Stored Procedure sending 3 parameters. It works fine.

Now i'm making some changes in the database and i realized that Stored Procedure should receive 4 parameters instead of 3 so it can do his work.

My question is: What could happen if i change the Stored Procedure without changing the Servlet? Will the Servlet crash due to the missing parameter?

I have this question because the servlet and the new version (with the SP call modified) will be working on the same database for a while for testing.

I've thinking of creating another SP, or changing both versions of the servlet. And yes, testing must be done on the same database :S

I want to know what you think. Thanks.

GF Rsrc Type: ConnectionPoolDataSource (no replies)

$
0
0
I just successfully created a MySQL rsrc in Glassfish (GF) using the instructions in the MySQL Connector/J manual.

One thing which got me scratching my head is that the manual recommended using the javax.sql.DataSource option when picking the Rsrc Type. In that same DropdownList, there is also the java.sql.ConnectionPoolDataSource option. Is the latter the one that truly supports connection-pooling ? When I picked the ConnectionPoolDataSource option, PING failed with "unknown command". javax.sql.DataSource worked fine.

What are your thots?

Thanks,
Arthur

Mysql connection via cmd prompt (no replies)

$
0
0
Hello all
I am able to connect to mysql db via java program but when I run it using cmd, it does not work.

java -jar iris.jar program-file=Vbra.txt naive unsafe-rules

Exception: com.mysql.jdbc.Driver

java.sql.SQLException: Data Source Unavailable, try connect() first...


Is there Any body who knows how to use Connect() via cmd prompt or any other way to connect ?

Thanking you in advance

problem with update (no replies)

$
0
0
hello my problem seems odd
I connect to my remote database with jdbc
a problem occurs during update
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: UPDATE command denied to user 'ramitnco_root' @ '41 .227.205.64 '; for table' connected '
but it's not a privileges problem because the user ramitnco_root have all privileges.
I can do update using mysql query browser whith same user same adress
and I can do update when I work with my database locally

MySQL Connector/J code cleanup (1 reply)

$
0
0
MySQL Connector/J has lots of code for MySQL version<5 compatibility. Now that MySQL support for versions<5 has ended, will you remove old compatibility code to be able to more easily fix current bugs in MySQL Connector/J?

Java JDBC local,remote connection error (no replies)

$
0
0
Hi Everyone

I have been developing a Java based system to monitor a number of computers of a local network. To do this I have a simple Java application (with JDBC connectivity) that updates a database every 60 seconds with the information about the specific client the java application is running on.

This all works fine, however when I come to run the same application on the server that holds the MySQL database I got the following error:

SEVERE: null
java.sql.SQLException: Data source rejected establishment of connection, message from server: "Host '192.168.1.9' is not allowed to connect to this MySQL server"
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:650)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1808)
at com.mysql.jdbc.Connection.<init>(Connection.java:452)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:411)
at java.sql.DriverManager.getConnection(DriverManager.java:620)
at java.sql.DriverManager.getConnection(DriverManager.java:200)

I believe it may have something to do with the mySQL setting 'bind-address' settings (which is currently set to 192.168.1.9).

Any suggestions would be greatly appreciated :)

David

Invoking stored procedure - is catalog name ever required? (no replies)

$
0
0
I've seen the stored procedure invocation documented as:
   {call demoSp(?, ?)}
I'm building up my invocation string from JDBC metadata.
The PROCEDURE_CAT column is populated with the name of the database
    url: jdbc:mysql://localhost:3306/emp
                                   ^^^ database name

    // useful fields in databaseMetaData.getProcedures() ResultSet
    public static final int PROCS_INFO_CATALOG = 1;//catalog (may be null)
    ...
    ResultSet procsInfo = databaseMetaData.getProcedures(catalogPattern,
        schemaPattern, procedurePattern);
    String actualCatalogName = procsInfo.getString(PROCS_INFO_CATALOG);
           ^^^^^^^^^^^^^^^^^ contains "emp"
Thus, my invocation string becomes:
   {call emp.demoSp(?, ?)}

In older versions of the Connector, this seemed to work; however, in
version 5.1.13 of Connector/J, I'm getting an exception:
    Parameter index of n is out of range (a, b)  {values n, a, b vary based on
                                                  number of arguments}
(and yes, I've opened a bug on this http://bugs.mysql.com/bug.php?id=57183)

I can change my code to not include the catalog name ... but is there ever
any circumstance under which it does becomes required?

Thanks in advance,
Mike Norman
Viewing all 884 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>