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

loadbalance url : statement vs preparedstatement (no replies)

$
0
0
Hi,

Is there a difference between using regular statements vs using prepared statements in regards to rebalancing behaviour of connector/j?

I execute the following:

1. get connection from driver
2. make the first host (host1) unavailable
3. execute some sql on the connection (should fail). sql="select field1 from nonexistingtable"

url: "jdbc:mysql:loadbalance://host1,host2:3306/TESTDB?autoReconnect=false&connectTimeout=5000&socketTimeout=30000&relaxAutoCommit=true&failOverReadOnly=false&characterEncoding=UTF-8"

connector/j : 5.1.18

java: 1.6.0.37

If i execute the 3rd step using regular statements, a physical connection to host2 is established. (query fails after sockettimeout ms)

But if i execute the same step using a prepared statement, no physical connections are established to host2. (query fails after sockettimeout ms)

Is there a reason why they behave differently? Is this expected behaviour?

Actually i am trying to validate the connection, and i read somewhere that the validation query should start with "/* ping */", especially for a loadbalanced configuration. Does anyone know what this "ping" query actually does?

thank you

Viewing all articles
Browse latest Browse all 884

Trending Articles



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