All Questions

240
votes
12answers
381898 views

Connect Java to a MySQL database

How do you connect to a MySQL database in Java?
125
votes
24answers
336017 views

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

I'm working on getting my database to talk to my Java programs. Can someone give me a quick and dirty sample program using the JDBC? I'm getting a rather stupendous error: Exception in thread "main...
38
votes
5answers
47693 views

Show JDBC ResultSet in HTML in JSP page using MVC and DAO pattern

I'm implementing MVC using JSP and JDBC. I have imported a database class file to my JSP file and I would like to show the data of a DB table. I don't know how I should return the ResultSet from the J...
281
votes
25answers
259600 views

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 ? plac...
21
votes
13answers
106169 views

How to install JDBC driver in Eclipse web project without facing java.lang.ClassNotFoundexception

There is a VERY similar question to mine but in my case I don't have any duplicate jars in my build path, so the solution does not work for me. I've searched google for a couple of hours now, but non...
282
votes
7answers
197987 views

How to get the insert ID in JDBC?

I want to INSERT a record in a database (which is Microsoft SQL Server in my case) using JDBC in Java. At the same time, I want to obtain the insert ID. How can I achieve this using JDBC API?
129
votes
25answers
426322 views

Solving a "communications link failure" with JDBC and MySQL

I'm trying to connect to the local MySQL server but I keep getting an error. Here is the code. public class Connect { public static void main(String[] args) { Connection conn = null; ...
40
votes
7answers
61986 views

The infamous java.sql.SQLException: No suitable driver found

I'm trying to add a database-enabled JSP to an existing Tomcat 5.5 application (GeoServer 2.0.0, if that helps). The app itself talks to Postgres just fine, so I know that the database is up, user ca...
94
votes
13answers
150859 views

How to establish a connection pool in JDBC?

Can anybody provide examples or links on how to establish a JDBC connection pool? From searching google I see many different ways of doing this and it is rather confusing. Ultimately I need the code...
266
votes
13answers
274989 views

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]...

Previous Next