“Incorrect string value” when trying to insert UTF-8 into MySQL via JDBC?

This is how my connection is set: Connection conn = DriverManager.getConnection(url + dbName + “?useUnicode=true&characterEncoding=utf-8”, userName, password); And I’m getting the following error when tyring to add a row to a table: Incorrect string value: ‘\xF0\x90\x8D\x83\xF0\x90…’ for column ‘content’ at row 1 I’m inserting thousands of records, and I always get this error when the … Read more

Find Oracle JDBC driver in Maven repository

I want to add the oracle jdbc driver to my project as dependency (runtime scope) – ojdbc14. In MVNrepository site the dependency to put in the POM is: <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc14</artifactId> <version>10.2.0.3.0</version> </dependency> of course this does’t work as it is not in the central repository used by maven. 2 questions: How do I find … Read more

Connection pooling options with JDBC: DBCP vs C3P0 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 8 months ago. Improve this question What is the best connection pooling library available for Java/JDBC? I’m considering the 2 main candidates (free / open-source): … Read more

To prevent a memory leak, the JDBC Driver has been forcibly unregistered

I am getting this message when I run my web application. It runs fine but I get this message during shutdown. SEVERE: A web application registered the JBDC driver [oracle.jdbc.driver.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. Any help … Read more

Connect Java to a MySQL database

How do you connect to a MySQL database in Java? When I try, I get java.sql.SQLException: No suitable driver found for jdbc:mysql://database/table at java.sql.DriverManager.getConnection(DriverManager.java:689) at java.sql.DriverManager.getConnection(DriverManager.java:247) Or java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Or java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver 14 Answers 14

PreparedStatement IN clause alternatives?

What are the best workarounds for using a SQL IN clause with instances of java.sql.PreparedStatement, which is not supported for multiple values due to SQL injection attack security issues: One ? placeholder represents one value, rather than a list of values. Consider the following SQL statement: SELECT my_column FROM my_table where search_column IN (?) Using … Read more

MySQL JDBC Driver 5.1.33 – Time Zone Issue

Some background: I have a Java 1.6 webapp running on Tomcat 7. The database is MySQL 5.5. Previously, I was using Mysql JDBC driver 5.1.23 to connect to the DB. Everything worked. I recently upgraded to Mysql JDBC driver 5.1.33. After the upgrade, Tomcat would throw this error when starting the app. WARNING: Unexpected exception … Read more