java - Setting JDBC Properties Using DataSource -
i connecting mysql database using datasource object.
datasource mysql = (datasource) context.lookup("jdbc/mysqldatasource"); connection conn = mysql.getconnection(); i want set property
rewritebatchedstatements=true for when doing batch uploads. have seen examples how when people using driver manager below:
string myconnectionstring = "jdbc:mysql://localhost:3307/mydb?" + "useunicode=true&characterencoding=utf-8" + "&rewritebatchedstatements=true"; try (connection con = drivermanager.getconnection(myconnectionstring, "root", "whatever")) how go setting property using datasource?
if cast datasource specific implementation you're using, able use get/set methods specific jdbc driver using.
import com.mysql.jdbc.jdbc2.optional.mysqldatasource; //... mysqldatasource mysql = (mysqldatasource) context.lookup("jdbc/mysqldatasource"); mysql.setrewritebatchedstatements(true); connection conn = mysql.getconnection(); see link reference: http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html
Comments
Post a Comment