The Artima Developer Community
Sponsored Link

Java Answers Forum
java.lang.NullPointerException at MyField.actionPerformed(MyField.java:580)

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
steps

Posts: 14
Nickname: spanishste
Registered: Nov, 2003

java.lang.NullPointerException at MyField.actionPerformed(MyField.java:580) Posted: Jan 31, 2004 4:33 PM
Reply to this message Reply
Advertisement
Hello,
I've a GUI in swing and I'm doing user authentication.Mysql is the
database.The user enters the username, password and it has to check to the ones
in the db table.
pls help me.
class Accounts {
public Connection connection;
public Statement statement;
public Accounts() {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
System.out.println("driver found");
} catch (Exception e) {
System.err.println("Unable to find and load driver");
System.exit(1);
}
connectToDB();
}
public void connectToDB() {
try {
connection = DriverManager.getConnection
("jdbc:mysql://localhost/accounts?user=root");
System.out.println("database connected");
statement = connection.createStatement();
/*if(statement == null) {
System.out.println("statement is null");
}
else {
System.out.println("statement created");
}*/
} catch(SQLException connectException) {
System.out.println(connectException.getMessage());
System.out.println(connectException.getSQLState());
System.out.println(connectException.getErrorCode());
System.exit(1);
}
}
private void displaySQLErrors(SQLException e) {
}
}
///////Button Action event code/////////////////
if (event.getActionCommand().equals(StopRC)){
try {
statement = connection.createStatement();<<<-----It points out the error here.This is line 580.
} catch (SQLException e1) {
e1.printStackTrace();
}
if(statement == null) {
System.out.println("statement is null");
}
username=Uname.getText();
password=Passwd.getText();
System.out.print ln(username);
System.out.println(password);
loadAccounts();

Topic: hi group !! Share your views on this........ Previous Topic   Next Topic Topic: what about netbeans?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use