Skip to main content

NetBeans 6.0 MySQL connection

1 reply [Last post]
Joined: 2008-01-02

I am trying to create an application to do stats on some tables in MySQL
Below is code that I am working on. The words that are underlined are highlighted in NB stating that the Fields are not used. If anyone can explain why this is, I would greatly appreciate it?

* To change this template, choose Tools | Templates
* and open the template in the editor.

package Statistics;
import java.sql.*;
import java.util.*;
import javax.swing.table.*;
import java.lang.*;

* @author RichardDunne
public class stats {
private String Connector = "com.mysql.jdbc.Driver";
private String DATABASE_URL = "jdbc:mysql://localhost:3306/Questions";
private String Username="root";
private String Password="password";

private Connection connection;
private Statement stmt;
private ResultSet countRows;
private boolean connected = false;

public void Connect(String Connector, String DATABASE_URL, String Query) throws SQLException, ClassNotFoundException
connection = DriverManager.getConnection(DATABASE_URL,Username,Password);
stmt = connection.createStatement();
if(!connected) throw new IllegalStateException("Connection failed");

public void countRows()
ResultSet countRows = stmt.executeQuery("select count(*) as countRows from answers;");
catch(SQLException sqlException)



Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2008-04-09

Have you already created the database "Questions" and table "answers" in mysql?

If you use tomcat have you already put the connector for mysql?