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

Multiple Colum Update (1 reply)

$
0
0
Hi i getting trouble executing this Updatequery:

"UPDATE "
+ " SET firstname =?, "
+ " lastname =?, "
+ " company =?, "
+ " department =?, "
+ " legalform =? "
+ " WHERE cid = '"+cid+"'";

On my MySQL Workbench it wroks fine, but i cannot execute it with JDBC
using executeUpdate

Is it generaly possible using MySQL Connector/J executing "one" Update Statement
and changing multiple Colums values?

com.mysql.jdbc.exceptions.MySQLSyntaxErrorException (2 replies)

$
0
0
Error:

com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? AND games.GAMEDATE < ? AND ( games.HOMETEAM = ? OR games.AWAYTEAM = ? )' at line 1


MySQL version: 5.1.32
IDE: MyEclipse 6.0

MYSQL connector version: 5.0.8

Actual query JVM tries to run is : SELECT * FROM imageDATA WHERE imageDATE > '2009-12-01' AND imageDATE < '2009-12-31' AND ( HOME = 'India' OR AWAY = 'India' )

This runs fine if I try it on cmd.

Need help!!!

HELP!: Java Communications Link Error (no replies)

$
0
0
I am trying to get my Java program to connect to a remote computer. However, the ping latency between the two computers is less than 1 ms. I use one for Database and Website and the other one to run the actual game server on.

///////PIECE OF CODE//////////////

public synchronized static void createConnection() {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://67.214.120.165/highscores","misthalin","lol");
statement = conn.createStatement();
} catch (Exception e) {
e.printStackTrace();
}
}

///////////////////////////////

And this method is called later on.
What can i do to fix this exception?

Exception in thread "main" com.mysql.jdbc.CommunicationsException: Communications link failure

---------------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
Last packet sent to the server was 0 ms ago.
at com.mysql.jdbc.SQLError.createCommunicationsExcept ion(SQLError.java:1070)
at com.mysql.jdbc.ConnectionImpl.createNewIO(Connecti onImpl.java:2104)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:729)
at com.mysql.jdbc.ConnectionImpl.getInstance(Connecti onImpl.java:298)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:283)
at java.sql.DriverManager.getConnection(libgcj.so.81)
at java.sql.DriverManager.getConnection(libgcj.so.81)
at test2.main(test2.java:6)
Caused by: java.io.CharConversionException
at gnu.gcj.convert.Input_iconv.read(libgcj.so.81)
at java.lang.String.init(libgcj.so.81)
at java.lang.String.<init>(libgcj.so.81)
at com.mysql.jdbc.SingleByteCharsetConverter.<init>(SingleByteCharsetConverter.java:153)
at com.mysql.jdbc.SingleByteCharsetConverter.initChar set(SingleByteCharsetConverter.java:108)
at com.mysql.jdbc.SingleByteCharsetConverter.getInsta nce(SingleByteCharsetConverter.java:86)
at com.mysql.jdbc.ConnectionImpl.getCharsetConverter( ConnectionImpl.java:2767)
at com.mysql.jdbc.StringUtils.getBytes(StringUtils.ja va:681)
at com.mysql.jdbc.Buffer.writeStringNoNull(Buffer.jav a:665)
at com.mysql.jdbc.Buffer.writeString(Buffer.java:639)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:12 87)
at com.mysql.jdbc.ConnectionImpl.createNewIO(Connecti onImpl.java:2032)

--------------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////

Help me please.Error Report about Connector/MXJ package (no replies)

$
0
0
Hi,

I downloaded " mysql-connector-mxj-gpl-5-0-11" in windows X86. But lib folder was empty, so I could not find " aspectjrt.jar ". I need " aspectjrt.jar " to set CLASSPATH.

Can you help me?

Comms failure part-way through query (no replies)

$
0
0
Hi all.

I'm getting some problems with comms failures that periodically happen part-way through some large queries on my Java-based client.

They seem to happen between 15 mins - 1 hour after starting the query. My net_read_timeout is set to 3600 and my net_write_timeout is set to 36000, so I don't think I'm hitting these.

Here is a stack trace:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 12 milliseconds ago.  The last packet sent successfully to the server was 1,667,496 milliseconds ago.
	at sun.reflect.GeneratedConstructorAccessor18.newInstance(Unknown Source) [na:na]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) [na:1.6.0_18]
	at java.lang.reflect.Constructor.newInstance(Unknown Source) [na:1.6.0_18]
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:409) [mysql-connector-java-5.1.13-bin.jar:na]
	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1118) [mysql-connector-java-5.1.13-bin.jar:na]
	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3055) [mysql-connector-java-5.1.13-bin.jar:na]
	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2941) [mysql-connector-java-5.1.13-bin.jar:na]
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3489) [mysql-connector-java-5.1.13-bin.jar:na]
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919) [mysql-connector-java-5.1.13-bin.jar:na]
	at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1416) [mysql-connector-java-5.1.13-bin.jar:na]
	at com.mysql.jdbc.RowDataDynamic.nextRecord(RowDataDynamic.java:418) [mysql-connector-java-5.1.13-bin.jar:na]
	at com.mysql.jdbc.RowDataDynamic.next(RowDataDynamic.java:397) [mysql-connector-java-5.1.13-bin.jar:na]
	at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7171) [mysql-connector-java-5.1.13-bin.jar:na]
	at org.apache.commons.dbcp.DelegatingResultSet.next(DelegatingResultSet.java:207) [commons-dbcp-1.4.jar:1.4]
	at org.apache.commons.dbcp.DelegatingResultSet.next(DelegatingResultSet.java:207) [commons-dbcp-1.4.jar:1.4]
	at org.apache.commons.dbcp.DelegatingResultSet.next(DelegatingResultSet.java:207) [commons-dbcp-1.4.jar:1.4]
	at 
[SNIPPED]
	... 4 common frames omitted
Caused by: java.io.EOFException: Can not read response from server. Expected to read 104 bytes, read 9 bytes before connection was unexpectedly lost.
	at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2502) [mysql-connector-java-5.1.13-bin.jar:na]
	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3008) [mysql-connector-java-5.1.13-bin.jar:na]
	... 19 common frames omitted

The above error occurred about 25 mins after starting the query. This is a pretty large query, returning many millions of (sorted) results.

Any ideas?

Thanks.

Neil.

DriverManager.registerDriver not working for me (no replies)

$
0
0
I want to create a java application where i want to connect to a mysql database and supply the driver class/jar at runtime.


I tried this:



DriverManager.setLogStream(System.out);
String strJar = "G:/mysqlConnectors/mysql-connector-java-5.1.14-bin.jar";
File file = new File(strJar);
if(file.exists()) {
URL jarfile = new URL("jar", "","file:" + file.getAbsolutePath()+"!/");
System.out.println(jarfile);
ClassLoader cl = URLClassLoader.newInstance(new URL[] {jarfile });
clas = cl.loadClass("com.mysql.jdbc.Driver");
Class<? extends Driver> driverClass = clas.asSubclass(Driver.class);
System.out.println(driverClass.getName());
DriverManager.registerDriver(driverClass.newInstance());
System.out.println("********"+System.getProperty("jdbc.drivers"));
DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "pranay"); //this line gives exception.
} else {
System.out.println("Jar File not found in path: "+strJar);
}



the last line DriverManager.getConnection gives me exception.


Output of the code is:

jar:file:G:\mysqlConnectors\mysql-connector-java-5.1.14-bin.jar!/
com.mysql.jdbc.Driver
JdbcOdbcDriver class loaded
registerDriver: driver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@60aeb0]
DriverManager.initialize: jdbc.drivers = null
JDBC DriverManager initialized
registerDriver: driver[className=com.mysql.jdbc.Driver,com.mysql.jdbc.Driver@16caf43]
registerDriver: driver[className=com.mysql.jdbc.Driver,com.mysql.jdbc.Driver@66848c]
********null
DriverManager.getConnection("jdbc:mysql://localhost:3306/test")
trying driver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@60aeb0]
*Driver.connect (jdbc:mysql://localhost:3306/test)
skipping: driver[className=com.mysql.jdbc.Driver,com.mysql.jdbc.Driver@16caf43]
skipping: driver[className=com.mysql.jdbc.Driver,com.mysql.jdbc.Driver@66848c]
getConnection: no suitable driver found for jdbc:mysql://localhost:3306/test
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/test
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.global.pranay.multijar.MultiJar.testConnection(MultiJar.java:35)
at com.global.pranay.multijar.MultiJar.testSingleClassLoader(MultiJar.java:63)
at com.global.pranay.multijar.MultiJar.main(MultiJar.java:48)
SQLException: SQLState(08001)



Can you please help what is the problem?
Thanks in advance.

getMetaData().getColumns thorws OutOfMemoryError (4 replies)

$
0
0
Hi,

I'm trying to use the getColumns method of the JDBC getMetadata() object. I'm using the Connector/J version 5.1.7.

The method call throws OutOfMemoryError, because the db has very large schema.
Is there a way to avoid that error?

If there is no way to avoid it I can implement my own getColumns and avoid this method call but I wanted to know the inner implementation of it - is there a way to find the source code? I couldn't find a donwload link for it.

Thanks.

Tomcat 6 Pooled connections not seeing effects of transactions ? (no replies)

$
0
0
Fairly new to mysql and I am sure this has been solved, but in my little java app, it seems that the effects of an sql update are not immediately 'visible' to other db threads.
My tester updated a record, and upon my searching it up via a select, I was not seeing the change - even though he was seeing it.. Its like we are working on our own snapshot of the data.

Tomcat 6 and the latest Connector/J
Any suggestions as to where to begin solving this? Thank you in advance.

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure (2 replies)

$
0
0
Numerous people have reported this exception over recent years. For me, it has occurred when MySQL is on localhost and I am accessing it with Connector-J; the exception is raised sporadically on a lightly loaded website. I have tried various solutions that other people have suggested:

I have updated to the latest version of Connector-J (5.1.14)

I have
props.setProperty("autoReconnect","true");
props.setProperty("autoReconnectForPools","true");
props.setProperty("reconnectAtTxEnd","true");
for opening the connection to the database.

I have tried
try {stmt.executeQuery("/* ping */ select 1");} catch (Exception ex) {}
prior to each request.

None have solved the problem. The only way that I have found so far to be reliable is to open the connection to the database prior to each request.

lost german characters (no replies)

$
0
0
hello all

i have written a java-class to fetch data from a mysql-database. now everithing works fine except that all non ascii-characters are lost and instead the question marks are on their place.

so here the code a bit shorten:

Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://" + MYSQL_HOST + "/" + MYSQL_DB + "?user=" + MYSQL_USER + "&password=" + MYSQL_PASS + "";

conn = DriverManager.getConnection(url);
java.sql.Driver driver = DriverManager.getDriver(url);

Statement s = conn.createStatement();

s.executeQuery ("SELECT * FROM TBL_NAME");
ResultSet rs = s.getResultSet();


while (rs.next ()) {
...


then result look's like this:

convention pour le r?glement des diff?rends relatifs aux investissements
ausserdienstliche t?tigkeit

in using mysql 5.1.49-3 on debian-testing/linux

thans for any hints.

Medical School Admissions (no replies)

$
0
0
MD admit provides Medical School Admissions consulting services to anyone considering applying to medical school. Medical school applicants often underestimate the competitiveness of Medical School Admissions and apply to fewer schools than required to maximize success.

Error at SELECT with Parameter (?) - [1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1 (no replies)

$
0
0
Hi all,
I'm trying to do a simple SELECT passing a parameter (?) at WHERE clause but I'm getting the exeception:
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1
Funny that I made a INSERT with parameter at VALUES and it worked.
Any ideia?
Thx all

Eclipse Version: Helios Release Build id: 20100617-1415
MySQL Essential 5.1.53 win32
mysql-connector-java-5.1.14
Java SE-1.6

=== CODE ===
package ztest;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class Test910 {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Test910 test910 = new Test910();
test910.doExecute();
}
public void doExecute() throws Exception {
int rowCount = 0;
//
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/wal", "wal", "wal");
//
String sql = "";
sql += "SELECT EmbraerAircraftProjectGuid FROM wal.EmbraerAircraftProject WHERE EmbraerAircraftProjectCode = ?";
// sql +=
// "SELECT EmbraerAircraftProjectGuid FROM wal.EmbraerAircraftProject WHERE EmbraerAircraftProjectCode = '0141'";
//
PreparedStatement preparedStatement = conn.prepareStatement(sql);
preparedStatement.setString(1, "0141");
ResultSet resultSet = preparedStatement.executeQuery(sql); // <<--EXCEPTION
resultSet.last();
rowCount = resultSet.getRow();
resultSet.close();
preparedStatement.close();
conn.close();
//
System.out.println("RowCount = " + rowCount);
}
}
=== Exception ===
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
at com.mysql.jdbc.Util.getInstance(Util.java:382)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2620)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2570)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1474)
at ztest.Test910.doExecute(Test910.java:31)
at ztest.Test910.main(Test910.java:16)
=== End ===

MySql and Java Swings interface (no replies)

$
0
0
Hi all,

I Have made a Swing interface which is reading and writing on the database every 20 seconds. It works fine for some 3-4 days continuously but after that suddenly stops updating and reading the database. I am not able to understand what the issue can be. I have closed all the connections and checked for all the sockets.. Please help me as the this is like a headache for me and i m not able to move ahead due to this.

Thanks in Advance for help

Regards,
Yash Sharma

Looking for comparison between MysqlConnectionPoolDataSource and DBCP (no replies)

$
0
0
I'm back to java development since my left for some days.

DBCP is still widely used in many projects. But like many other modern JDBC driver, mysql provide a Datasource implementation as well.

DBCP seem to be a safer option, but I believe the mysql team did some improvement on their driver these days. I search around but only found few old article.

Is there any comparison table between MysqlConnectionPoolDataSource and DBCP?

I know Mysql in LGPL and DBCP is APL. But it doesn't matter to my project as we use spring and only depends on the DataSource interface.

How is their performance, unique feature, and the most important stability?

Select query on a table with 13 million of rows (no replies)

$
0
0
Hi guys,

I have been trying to perform a select query on a table which has 13 millions of entries however it took around 58 min to complete.

The table has 8 columns with 4 Primary keys looks like below:

PK SegmentID > INT
PK IPAddress > VARCHAR (45)
MAC Address > VARCHAR (45)
PK Application Name > VARCHAR (45)
Total Bytes > INT
Dates > VARCHAR (45)
Times > VARCHAR (45)
DateTime > DATETIME

The sql query format is :

select ipaddress, macaddress, sum(totalbytes), applicationname , dates,
times from appstat where segmentid = 1 and datetime between '2011-01-03
15:00:00.0' and '2011-01-04 15:00:00.0' group by ipaddress,
applicationname order by applicationname, sum(totalbytes) desc

Is there a way I can improve this query to be faster ?

Any feedback is welcomed.

Thank you.

--

Mus

Issue loading MySQL tables from delimited text files (no replies)

$
0
0
Hello,

We have a JAVA application that we developed to process product returns and have been using that application successfully for years. The application utilizes MySQL as the underlying database. Recently, I have been tasked with updating this application (i.e. MySQL, code changes, etc.) so that the app will run compatible with Windows Vista / Windows 7.

One of the problems that I've encountered is a significant delay when attempting to load the MySQL tables with data that is extracted from our ERP system. Data is downloaded into text files (delimited) based on certain criteria provided by the end user, a zip file of this downloaded data is created and then imported into the application. The data appears to load correctly into each of the tables, but the 13 to 15 minutes to load is unacceptable.

Provided below is code used to process one of the downloaded data files (i.e. text files) and upload in to the MySQL tables: (this process is used to upload all the text files).

public void loadReturnHdr(File file, boolean append)
throws IOException, FileNotFoundException, SQLException{
BufferedReader br = new BufferedReader(new FileReader(file));
if(!append){
getPsDeleteAllReturnHdrs().execute();
}
PreparedStatement stmt = getPsInsertReturnHdr();
stmt.clearBatch();
stmt.clearWarnings();
for(String rcd = br.readLine(); rcd != null; rcd = br.readLine()){
setPsInsertReturnHdr(stmt, rcd);
stmt.addBatch();
}
try{
stmt.executeBatch();
}catch(BatchUpdateException be){/* Ignore duplicate key errors */};

br.close();
}

HERE IS THE setPsInsertRetturnHdr method code:

private void setPsInsertReturnHdr(PreparedStatement stmt, String rcd) throws SQLException{
StringTokenizer st = new StringTokenizer(rcd,TAB_NL);
while(st.hasMoreTokens()){
stmt.clearParameters();
stmt.setBigDecimal(1, new BigDecimal(st.nextToken()));
stmt.setString(2, st.nextToken());
stmt.setString(3, st.nextToken());
stmt.setString(4, st.nextToken());
stmt.setString(5, st.nextToken());
stmt.setString(6, st.nextToken());
stmt.setString(7, st.nextToken());
stmt.setString(8, st.nextToken());
stmt.setString(9, st.nextToken());
stmt.setString(10, st.nextToken());
stmt.setString(11, st.nextToken());
try{
stmt.setBigDecimal(12, new BigDecimal(st.nextToken())); }catch(NumberFormatException nfe){
stmt.setBigDecimal(12, new BigDecimal(0));
}
stmt.setString(13, st.nextToken());
stmt.setString(14, st.nextToken());
stmt.setString(15, st.nextToken());
try{
stmt.setBigDecimal(16, new BigDecimal(st.nextToken()));
}catch(NumberFormatException nfe){
stmt.setBigDecimal(16, new BigDecimal(0));
}
stmt.setString(17, st.nextToken());
try{
stmt.setBigDecimal(18, new BigDecimal(st.nextToken()));
}catch(NumberFormatException nfe){
stmt.setBigDecimal(18, new BigDecimal(0));
}
stmt.setString(19, st.nextToken());
stmt.setString(20, st.nextToken());
stmt.setString(21, st.nextToken());
stmt.setString(22, st.nextToken());
stmt.setString(23, st.nextToken());
stmt.setString(24, st.nextToken());
stmt.setString(25, st.nextToken());
stmt.setString(26, st.nextToken());
stmt.setString(27, st.nextToken());
stmt.setBigDecimal(28, ZERO);
stmt.setBigDecimal(29, ZERO);
stmt.setString(30, BLANK);
stmt.setBigDecimal(31, ZERO);
stmt.setBigDecimal(32, ZERO);
stmt.setString(33, st.nextToken());
stmt.setString(34, st.nextToken());
stmt.setString(35, st.nextToken());
}
}



HERE IS THE INSERT STATEMENT

private PreparedStatement getPsInsertReturnHdr() throws SQLException{
if(psInsertReturnHdr == null){
psInsertReturnHdr = conn.prepareStatement(
"insert into returnhdr values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
}
return psInsertReturnHdr;
}

Thanks for any assistance,
Randy

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Too many connections (no replies)

$
0
0
I have file which uploads data to the remote mysql database, which runs on quartz timer, i get the following error. kindly some one help me out..

Thanks in advance

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
at com.mysql.jdbc.Util.getInstance(Util.java:382)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:931)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4046)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1296)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2338)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2371)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.GeneratedConstructorAccessor93.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at DataConnect.DBConnectionDist.<init>(DBConnectionDist.java:34)
at DataConnect.DataTransfer.<init>(DataTransfer.java:32)
at sun.reflect.GeneratedConstructorAccessor100.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.quartz.simpl.SimpleJobFactory.newJob(SimpleJobFactory.java:55)
at org.quartz.core.JobRunShell.initialize(JobRunShell.java:140)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:365)

Table Isolation and JDBC (no replies)

$
0
0
Hello,

Is it possible to permanently set a specific table to be read serializable (i.e. I need it so it can only be read from by one transaction at a time). I've been reading about setting global or session transaction isolation level, but I can't seem to find anything for just a single table.

On another note, I'm having a lot of difficulties trying to run stored procedures in Java using JDBC. The user has select, insert, and update permissions, but the following code:

Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://*server*:3306/*databaseName*?user=*username*&password=*password*");
CallableStatement cstmt = con.prepareCall("{CALL getBlock1()}");

where getBlock1() is the name of the (successfully created) stored procedure, gives me the error "java.sql.SQLException: User does not have access to metadata required to determine stored procedure parameter types. If rights can not be granted, configure connection with 'noAccessToProcedureBodies=true' to have driver generate parameters that represent INOUT strings irregardless of actual parameter types." I tried adding the "noAccessToProcedureBodies=true" to my connection url, but it throws the same error. Any ideas?

Thanks!

Problem calling function through java program (no replies)

$
0
0
I written a mysql function and it's working fine. In a java applicaion I executed a select query (which calls the mysql function) and got the ResultSet. I printed the resultset and got the values returned from mysql function.

My problem is, If I passed the resultset to another java class where i am iterating the resultset and displaying the data in an Excel sheet, mysql function is returning zero values.

thanks
tiru

Problem with loading driver (no replies)

$
0
0
1. import java.sql.Connection;
2. import java.sql.DriverManager;
3. import java.sql.SQLException;
4.
5. public class LoadDriver {
6. public static void main(String[] args) {
7. try {
8.
9. Class.forName("com.mysql.jdbc.Driver").newInstance();
10. } catch (Exception ex) {
11. ex.printStackTrace();
12. }
13. }
14. }

i get this error :

Exception in thread "main" java.lang.NoClassDefFoundError: LoadDriver
Caused by: java.lang.ClassNotFoundException: LoadDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: LoadDriver. Program will exit.


I already created a environment variable named CLASSPATH and give it value = C:\mysql-connector-java-5.1.14\mysql-connector-java-5.1.14-bin.jar.
What can be the problem. Please help. Thnx in advance.
Viewing all 884 articles
Browse latest View live