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

mysql-connector-java-5.1.30 compile error (no replies)


Multiple master hosts in JDBC connection string (1 reply)

$
0
0
Hi there,

My problem is the following: I need to set multiple hosts in JDBC connection string, like jdbc:mysql://192.168.0.1,192.168.0.2/mydb, but every one of them should be a master, not a slave, for me to have opportunity to write to second host if the first fails. Also they will all be working on the same port, so I would like to write port number just one time, but if it's impossible, string like jdbc:mysql://192.168.0.1:3306,192.168.0.2:3306/mydb also fits.

Thanks in advance

Behavior Change (no replies)

$
0
0
Dear all,

We are currently migrating an internal solution from a UNIX / mysql 5.0.67 server to a RedHat / mysql 5.6.16 server.
The solution consists of:

-MySQL DB.
-Web site manager / web interface (war deployed on Glassfish).
-Background Java processes (long operations).

(Evreything is in java using same connector: mysql-connector-java-5.1.18-bin.jar)

The web interface is the starting point of the solution, (updating, inseting, deleting whatever is necessary)
THEN
it launches or stop the background processes.

The background processes are using the LOCK TABLE and UNLOCK TABLE command for access exclusion.
The solution has been running without problems on the old server for almost 3 years, however on
the new server the solution is acting differently.

What is happening is that, the background processes are being blocked until the web connection terminates
(by user loggout or tab closing...) whereas before this wasn't the case.

I can clearly see the blocking happening from the cli :

mysql> show processlist;
+-----+-------+-----------------+----------------+---------+------+---------------------------------+------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+-----+-------+-----------------+----------------+---------+------+---------------------------------+------------------------------+
| 234 | user1 | localhost | NULL | Query | 0 | init | show processlist |
| 246 | user1 | localhost:56200 | myapp | Sleep | 21 | | NULL |
| 247 | user1 | localhost:56205 | myapp | Query | 13 | Waiting for table metadata lock | LOCK TABLES person WRITE |
| 248 | user1 | localhost:56206 | myapp | Query | 13 | Waiting for table metadata lock | LOCK TABLES person WRITE |
| 249 | user1 | localhost:56207 | myapp | Query | 13 | Waiting for table metadata lock | LOCK TABLES person WRITE |
| 250 | user1 | localhost:56208 | myapp | Query | 13 | Waiting for table metadata lock | LOCK TABLES person WRITE |
+-----+-------+-----------------+----------------+---------+------+---------------------------------+------------------------------+

It seems that even if only the DB/tcp connection is alive (persistent connection?) (but no actual sql commands are being sent)
the acquiring of the WRITE lock fails. Is this the expected behavior ? Did it change from version 5.0.67 to 5.6.16 ?
If yes, can the behavior be modified by a configuration setting or do we have to modify the web module ?

Thanks in advance for any tip.

Sql and java (2 replies)

$
0
0
Hi guys i need some help i have trying to modify the following dbquery to get id
public static ArrayList<Expenses> expensesByCategory(String searchPhrase){
// declare local variables
ArrayList<Expenses> expensesList = new ArrayList<Expenses>();

ResultSet rs = null;
DBController db = new DBController();
String dbQuery;

//Step 1 -connect to database
db.getConnection();

//step 2 - declare the SQL statement
dbQuery = "SELECT * FROM EXPENSES WHERE CATEGORY='" + searchPhrase +"'";


// step 3 - using DBController, use updateRequest method
rs = db.readRequest(dbQuery);
try{
while (rs.next()){
int eID = rs.getInt("id");
String spend = rs.getString("dateSpend");
String cat = rs.getString("category");
double amt = rs.getDouble("amount");
String cont = rs.getString("content");

Expenses ex = new Expenses(eID, spend, cat, amt, cont);
expensesList.add(ex);
}
}
catch (Exception e) {
e.printStackTrace();
}
// step 4 - close connection
db.terminate();
return expensesList;
}
i have tried to modify it to work with and int here is what i got
public static ArrayList<AthleteEntity> athleteByID(int searchPhrase){
// declare local variables
ArrayList<AthleteEntity> athleteList = new ArrayList<AthleteEntity>();

ResultSet rs = null;
DBController db = new DBController();
String dbQuery;

//Step 1 -connect to database
db.getConnection();

//step 2 - declare the SQL statement
dbQuery = "SELECT * FROM ATHLETEINFORMATION WHERE ID ==>1 AND ID <= 100000";


// step 3 - using DBController, use updateRequest method
rs = db.readRequest(dbQuery);
try{
while (rs.next()){
int eID = rs.getInt("id");
String Name = rs.getString("Name");
String Dob = rs.getString("Dob");
String idnumber = rs.getString("idnumber");
String contact= rs.getString("contact");
String gender= rs.getString("gender");
String sportplayed= rs.getString("sportplayed");


AthleteEntity at = new AthleteEntity (eID, Name, Dob, idnumber, contact,gender,sportplayed);
athleteList.add(at);
}
}
catch (Exception e) {
e.printStackTrace();
}
// step 4 - close connection
db.terminate();
return athleteList;
}
}
i want to print in out in this tbllist ArrayList<AthleteEntity>result=AthleteEntity.athleteByID(searchPhrase);
i cant seem to make it work as i want to print a range of id from 1
any hellp appreciated thanks

Error when performing heavy queries (pentaho) (no replies)

$
0
0
Hi. When I perform hard queries in pentaho, the following occurs:
< 60 sec: mysql executes the query, pentaho displays query execution
after 60 sec: mysql executes the query, pentaho does not displays query execution
I tried to change the following parameters of mysql jdbc-connection:
netTimeoutForStreamingResults = 600
enableQueryTimeouts = false
And in mysql parameter:
net_write_timeout = 600
But nothing changes.
OS: Windows 7

Urgent J Connector URL Syntax for MySQL ignore-spaces Option (no replies)

$
0
0
Hi

I need help i was trying to connect to MySQL Server Using JDBC Driver I am using Powerbuilder 12.5 to connect to Database server but PowerBuilder application required the option ignore-spaces.

Previously i was doing this using changing in my.ini files whenever it was standalone machine now i just can't with database server.

I need this option to be set from my application following is the code to connect
to database server how do i set the property in URL?

"Driver='com.mysql.jdbc.Driver',URL='jdbc:mysql://localhost:3306/mydb"

i am just few steps behind please help me otherwise i have been forsed to used ODBC Connection

Which one is better ODBC / JDBC ? (no replies)

$
0
0
Hi i set up my applicaiton to connect using ODBC & JDBC both able to connect to MySQL local database, and now next step is to connect to web database. In my application i have to build some report from scratch which are building on stored procedure resultset. Reports build using ODBC now work when turn on JDBC So now i have to make a decision that should i go with JDBC / ODBC.

In terms of Simplicity / Security / Portability / Features / Speed?

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

$
0
0
Hello everyone. I've a problem with the connection to the MySQL database too.
I think there is a problem with the url or something else. DriverManager.getConnection(url, username, password); throws an exception.
I've tried the both:
String url = "jdbc:mysql://sql-4.radyx.ru/rashad47622";
and
String url = "jdbc:mysql:sql-4.radyx.ru/rashad47622";
but the result is the same.
code is:

public void readDataBase() throws Exception {
// this will load the MySQL driver, each DB has its own driver
try {
System.out.println("Loading driver...");
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Driver loaded!");
} catch (ClassNotFoundException e) {
throw new RuntimeException(
"Cannot find the driver in the classpath!", e);
}
// setup the connection with the DB.
String url = "jdbc:mysql://sql-4.radyx.ru/rashad47622";
String username = "myusername";
String password = "mypassword";
try {
System.out.println("Connecting database...");
connection = DriverManager.getConnection(url, username, password);
System.out.println("Database connected!");
} catch (SQLException e) {
throw new RuntimeException("Cannot connect the database!", e);
} finally {
System.out.println("Closing the connection.");
if (connection != null) try { connection.close(); } catch (SQLException ignore) {}
System.exit(0);
}

try {
statement = connection.createStatement();
...


Full StactTrace:

Loading driver...
Driver loaded!
Connecting database...
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1137)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:356)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2504)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2541)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2323)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:832)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:417)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:344)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at de.vogella.mysql.first.MySQLAccess.readDataBase(MySQLAccess.java:30)
at de.vogella.mysql.first.test.Main.main(Main.java:8)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.<init>(Socket.java:425)
at java.net.Socket.<init>(Socket.java:241)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:258)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:306)
... 16 more
Closing the connection.

Connecting to Remote DB using JDBC, Connection Time Out (no replies)

$
0
0
I am trying to just edit my mysql database from a remote ip address(my house). The server is at a friends house and we are just doing some development. I am fairly new to mysql and networking but I know my way around for the most part. I am stuck at the moment and not sure what I am missing or doing wrong. Thank You

-I have edited the bind address file and commented it out to accept all ip address.
-I have granted permissions to my user at the ip address that I am using at my house. Show Grants for user@ipaddress shows the persmissions were granted.
-3306 Port was opened on mysql server.

Java App code is below and the stack trace is posted below that.



public static void main(String args[]){
String user = "user";
String pass = "pass";
String dbtime;
String dbUrl = "jdbc:mysql://ipaddress:3306/ASN";
String dbClass = "com.mysql.jdbc.Driver";
String query = "Select * FROM users";

try {

Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection (dbUrl, user, pass);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);

while (rs.next()) {
dbtime = rs.getString(1);
System.out.println(dbtime);
} //end while

con.close();
} //end try

catch(ClassNotFoundException e) {
e.printStackTrace();
}

catch(SQLException e) {
e.printStackTrace();
}

} //end main

}


STACK TRACE

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1137)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:355)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2490)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2527)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2309)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:419)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:344)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at test.main(test.java:17)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.<init>(Socket.java:425)
at java.net.Socket.<init>(Socket.java:241)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:258)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:305)
... 15 more
BUILD SUCCESSFUL (total time: 21 seconds)

Mysql and Hibernate (no replies)

$
0
0
I disabled autocommit in Mysql and enabled it in Hibernate. It is working fine in Local machine and one environment but logging integrity constraint violation in other Environment. Can someone please suggest..?

MySQLQueryInterruptedException while no one killed the query (1 reply)

$
0
0
We started seeing exceptions MySQLQueryInterruptedException while there is no other thread that would killed executing query.
The versions: MySQL Innodb 5.5, JDBC 5.1.25 (from Maven repo)

The exception happens just milliseconds after query has been run (I've seen instances where there are only 2 milliseconds of time in between).

What could be the reason for these? Is it known bug?
The server is sure busy at the time this happens, but there are still number of connections available (we have 1000 connections available for that user, the error occurs when only about 200 are active)

Thanks,
Nikolay

I updated to Foundation 5.4.5 (no replies)

$
0
0
I'm having this problem too, ever since I updated to Foundation 5.4.5 (and now the same in 5.4.6).

Here's what I did to test it just now:

foundation new ftest
cd ftest
mkdir stylesheets
bundle
bundle exec compass compile

This process generates a file stylesheets/app.css that is only 47,261 bytes long.
I get no errors, just a much smaller app.css than it should be.

Here are the versions of some of the key pieces:

foundation version:
v1.0.4

compass version:
Compass 1.0.1 (Polaris)

bundle version:
Bundler version 1.3.5

ruby --version
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]

Running Ubuntu 14.04

www.reddit.com/r/NLCS2k14/comments/2iy44z/

setTimestamp Time Zone Ignored in ServerPreparedStatement (no replies)

$
0
0
As mentioned in http://bugs.mysql.com/bug.php?id=15604 there have been several bugs concerning time zones which should be fixed using the new code by setting useLegacyDatetimeCode=false.

One of the issues that has been fixed for the PreparedStatement is that now the time zone of the Calendar specified by the setTimestamp(int parameterIndex, java.sql.Timestamp x, Calendar cal) call is used to format the given Timestamp.

Why is this not the case for the ServerPreparedStatement?
The corresponding method setTimestampInternal(int parameterIndex, java.sql.Timestamp x, Calendar targetCalendar, TimeZone tz, boolean rollForward) simply ignores the given time zone tz if the legacy code is switched off.

Is this a bug?

ReplicationDriver [Possible Bug?] Internal MySQLConnection object always connects to the same host? (1 reply)

$
0
0
Greetings ,


We use MySQL master-slave setup to store data used in our REST APIs.
We are planing to direct to master db-host or to slave db-host depend the a REST request parameter.
To achieve this , we use MySQL ReplicationDriver. We use MyBatis as a layer between DB and our API.Spring is being used as the IOC framework.

We have defined two methods as follows , which the same logic to retrieve data from the DB. Only difference between these two methods is, one method has "readOnly=true" in @Transactional annotation, which will direct to "slave", and the other has "readOnly=false" which will direct to "master".



@Override
@Transactional(value = "itemTrxManager", readOnly = true, rollbackFor = Exception.class)
public Item getShopItemFromSlave(ItemGetKey itemKey, Options... opts) throws ItemException {
..
}

@Override
@Transactional(value = "itemTrxManager", readOnly = false, rollbackFor = Exception.class)
public Item getShopItemFromMaster(ItemGetKey itemKey, Options... opts) throws ItemException {
..
}



But we noticed that internally ReplicationDriver (MySQLConnection object) always direct to the first host it connects to , and doesn't change even after the change of "readOnly" flag.

ie : after starting our API , if we send request to use "slave" , ReplicationDriver will use "slave host" and even when we change to use "master", it still direct to "slave host". Otherway around is the same : after starting our API , if we send request to use "master" , ReplicationDriver will use "master host" and then if change to use "slave", it still direct to "master host".

We noticed that all the logs (Apache DBCP,Spring DAO , MyBatis logs) shows it connects to the correct host , but after debugging we figured out the issues is in MySQL driver classes (MySQLConnection objects shows incorrect host names).ie, Connection object retrieved from Apache DBCP DataSource and the internal MySQLConnection object shows different host info.

For example ,following shows a snippet from our logs .Even though it says it connects to "slave" , when debugging, the MySQL Drivers internal ReplicationDriver objects has information about "master".








DEBUG [http-8080-2] [AbstractPlatformTransactionManager.java:365] - Creating new transaction with name [com.foo.bar.item.core.businesslogic.impl.MerchantCategoryBusinessLogicImpl.listMerchantCategory]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; 'itemTrxManager' DEBUG [http-8080-2] [DataSourceTransactionManager.java:204] - Acquired Connection [jdbc:mysql://master-host:3301/, UserName=item_user@10.9.203.50, MySQL Connector Java] for JDBC transaction DEBUG [http-8080-2] [DataSourceUtils.java:153] - Setting JDBC Connection [jdbc:mysql://master-host:3301/, UserName=item_user@10.9.203.50, MySQL Connector Java] read-only

DEBUG [http-8080-2] [Slf4jImpl.java:47] - Creating a new SqlSession DEBUG [http-8080-2] [Slf4jImpl.java:47] - Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@329203a8] DEBUG [http-8080-2] [Slf4jImpl.java:47] - JDBC Connection [jdbc:mysql://slave-host:3306/, UserName=item_user@10.9.203.50, MySQL Connector Java] will be managed by Spring DEBUG [http-8080-2] [Slf4jImpl.java:47] - ooo Using Connection [jdbc:mysql://slave-host:3306/, UserName=item_user@10.9.203.50, MySQL Connector Java] DEBUG [http-8080-2] [Slf4jImpl.java:47] - ==>  Preparing: select merchant_category_id, custom_category_id, merchant_id, parent_id, sibling_position, image_url, create_time, update_time from glb_merchant_cat_tbl where merchant_id=?

. . .

DEBUG [http-8080-2] [Slf4jImpl.java:47] - Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@329203a8] DEBUG [http-8080-2] [Slf4jImpl.java:47] - Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@329203a8] DEBUG [http-8080-2] [DataSourceUtils.java:222] - Resetting read-only flag of JDBC Connection [jdbc:mysql://slave-host:3306/, UserName=item_user@10.9.203.50, MySQL Connector Java] DEBUG [http-8080-2] [DataSourceTransactionManager.java:322] - Releasing JDBC Connection [jdbc:mysql://master-host:3301/, UserName=item_user@10.9.203.50, MySQL Connector Java] after transaction DEBUG [http-8080-2] [DataSourceUtils.java:332] - Returning JDBC Connection to DataSource



How so solve this issue ? This might be a bug in ReplicationDriver ?

Socketfactory implementation example (4 replies)

$
0
0
Hi everybody,
is there somewhere a code example how to implement socketfactory as a class in java? What I need is information on how to use connect, beforehandshake and afterhandshake methods with truststore and keystore for a two way handshake.

Thank you in advance!

Yours
Ralph

NonRegisteringDriver illegally accessing "protected" member of class com/mysql/jdbc/ConnectionImpl (3 replies)

$
0
0
Hello,

I use MySQL Connector/J 5.1.33 and my setup is Websphere 8.5.5.0 and mysql on Windows 7 test machine (localhost).
Inside websphere, I set the property url to "jdbc:mysql://localhost:3306/test" and I use JAAS/J2C for authentication.

While trying to setup a mysql jdbc provider/data source in websphere, I am getting the following strange error:

[11/11/2014 15:25:36:179 EET] 00000136 DataSourceCon E DSRA8040I: Failed to connect to the DataSource. Encountered "": java.lang.IllegalAccessError: Class com/mysql/jdbc/NonRegisteringDriver illegally accessing "protected" member of class com/mysql/jdbc/ConnectionImpl
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:422)
at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:134)
at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:105)
at com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource.getPooledConnection(MysqlConnectionPoolDataSource.java:48)
at com.ibm.ws.rsadapter.DSConfigHelper$1.run(DSConfigHelper.java:1266)
at com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5474)
at com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5600)
at com.ibm.ws.security.core.SecurityContext.runAsSystem(SecurityContext.java:255)
at com.ibm.ws.rsadapter.spi.ServerFunction$6.run(ServerFunction.java:567)

....
[11/11/2014 15:25:36:185 EET] 00000136 MBeanHelper E Could not invoke an operation on object: WebSphere:name=DataSourceCfgHelper,process=server1,platform=dynamicproxy,node=2787w51Node01,version=8.5.5.3,type=DataSourceCfgHelper,mbeanIdentifier=DataSourceCfgHelper,cell=2787w51Node01Cell,spec=1.0 because of an mbean exception: java.sql.SQLException: java.lang.IllegalAccessError: Class com/mysql/jdbc/NonRegisteringDriver illegally accessing "protected" member of class com/mysql/jdbc/ConnectionImpl

Diging to some mysql source code that I found in the internet I saw inside NonRegisteringDriver.java a call:
Connection newConn = com.mysql.jdbc.ConnectionImpl.getInstance(
285 host(props), port(props), props, database(props), url);

This getInctance is a actually "protected" method...

Is this realy a bug or there is something else that I cannot figure out of? Could you please help?

Please note that I created a java jdbc source program and it connects successfully to the specific mysql server using the same connector/J.

Best regards,

Konstantinos

Sha256 Athentication Plugin (3 replies)

$
0
0
Hello Everybody,

i have issues using the sha256 authentication plugin together with the latest mysql-Jdbcconnector in my android app. After implementing a class which implements the authentication interface like in the example which comes with the mysqlconnector, I can't retriev the RSA public key from the server (method getPublicServerRSA() returns null!)
I created a user how it's discripted in the documentation: http://dev.mysql.com/doc/refman/5.6/en/sha256-authentication-plugin.html

I'm using the latest community server, I think it's 5.5.18, compiled with openssl. OpenSSL is switched off due to the configuration in my.cnf.

I tried to connect with the user which was created to use sha256_password. Tracing with wireshark shows me that I get a server greeting with the information of sha256 password. But then the client doesn't seem to send a request for the retrieval of the RSA-Key. After a couple of SYN, ACK and FIN telegrams at the TCP-Layer nothing happens anymore and my application throws an EOFException with the message that 4 bytes where expected but 0 bytes where received.

Can anyone help me on this issue?

Thank you in advance!

Stack Overflow Questions Tags Users Badges Unanswered Ask Question Getting image from server and saving to MySQL DB (no replies)

$
0
0
Im getting an image from server as InputStream and then saving it to mySQL database. It works when I use `Thread.sleep(5000);`. But if I dont use it no picture is saved to the DB or only one picture and half of it or less. So I understand that the program needs time writing image to the database, but how much time? This is the question, I would like to know exactly when it finished writing image to the database and can start with the next image. Below is my code:

ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {

int ID = rs.getInt(1);
String myName = rs.getString(2);

try {

String myCommand = "take picture and save /mydir/mydir2/mydir3" + myName + ".png";
telnet.sendCommand(myCommand); // Here taking a picture via telnet
// Thread.sleep(5000);// If I uncomment this line it works

String sqlCommand = "UPDATE my_table SET Picture = ? WHERE ID ='" + ID +"';";
PreparedStatement statement = conn.prepareStatement(sqlCommand);

String ftpUrl = "ftp://"+server_IP+"/mydir/mydir2/mydir3&quot; + myName + ".png;type=i";

URL url = new URL(ftpUrl);
URLConnection connUrl = url.openConnection();

//Thread.sleep(5000); // If I uncomment this line, it works too.

InputStream inputStreamTelnet = connUrl.getInputStream();

statement.setBlob(1, inputStreamTelnet);
int row = statement.executeUpdate();
if (row > 0) {
System.out.println("A picture was inserted into DB.");
System.out.println("Value of row(s) : " + row);
}

} catch (Exception e) {
e.printStackTrace();
}

} // End of while

I would expect to put the waiting(sleep) after `InputStream inputStreamTelnet = connUrl.getInputStream();` but it doesnt work when I put the sleep after this line. It works only when the sleep is before. Could someone explain me why and I would like to avoid using `Thread.sleep(5000);` and instead would like to wait exact time or not wait at all which will make the program faster also there might be a case saving the picture can take more than 5 seconds or maybe saving the picture doesnt take time but opening the url connection. There are 2 sleep lines on the code when I uncomment one of them the program works(saves the images to mysql DB successfully). I also verified on the server that the images exist but in the end I dont see them in the mysql DB.

MySQL version: '5.5.37-0ubuntu0.12.04.1'
MySQL connector : mysql-connector-java-5.1.7-bin
Java version : 1.8 32bit

What is the longevity of a "SET SESSION" statement? (1 reply)

$
0
0
We noticed that some of the queries we were running in our spring/java environment were coming back with truncated text after 1024 characters. The problem was group_concat_max_len was set too small. I tried modifying our database definition .sql file to include SET SESSION:

DROP DATABASE IF EXISTS acmedb;
CREATE DATABASE acmedb;
USE acmedb;
SET SESSION group_concat_max_len = 6999;
CREATE TABLE...

However this is not going into effect after a db reload. I have to do a jdbctemplate execute() statement with this code for it to propogate.
this.jdbcTemplateObject.execute("SET SESSION group_concat_max_len = 6999 ");

This fixes the problem... sometimes. I think eventually the session expires and this change is lost. What are the rules on mysql set session in terms of longevity of the call? I could put this statement before every query is executed but that seems like a lot of unnecessary overhead.

how to set the properties of jdbc using bind variables to reduce for DB performance? (1 reply)

$
0
0
Hi,

how to set the properties of jdbc using bind variables to improve for DB performance?

I use bind variables in database.
Can I set the properties of jdbc for the bind variables to improve DB performance instead?
Viewing all 884 articles
Browse latest View live


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