File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes I got runtime error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "I got runtime error" Watch "I got runtime error" New topic
Author

I got runtime error

Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 180

I got the runtime error when i press the Login button for the second time
This is my error message and pragram,Please Help me :-
#
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x77f4200b, pid=2680, tid=256
#
# Java VM: Java HotSpot(TM) Client VM (1.6.0_03-b05 mixed mode, sharing)
# Problematic frame:
# C [ntdll.dll+0x200b]
#
# An error report file with more information is saved as hs_err_pid2680.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
Press any key to continue...





//PROGRAM

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.DriverManager;



public class TestLogin extends JFrame implements ActionListener
{
private JButton b;
private JTextField t;
private JPasswordField pf;
JLabel l1,l2,l3;

Connection c;
PreparedStatement stat;
ResultSet res;


public TestLogin()
{
setVisible(true);
setSize(300,200);

JPanel p = new JPanel();
p.setBackground(java.awt.Color.YELLOW);
add(p);

l1= new JLabel("User Name");
l2= new JLabel("Password");
l3 = new JLabel("");

t = new JTextField(15);
pf = new JPasswordField(15);

b= new JButton("login");
b.addActionListener(this);

p.add(l1);
p.add(t);
p.add(l2);
p.add(pf);
p.add(b);
p.add(l3);


try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c =DriverManager.getConnection("jdbcdbc:AshokDb","sa","");
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"could'nt load the driver :"+e,"Error message",JOptionPane.ERROR_MESSAGE);
}




}
public static void main(String[] args)
{
new TestLogin();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b)
{
try
{
stat=c.prepareStatement("select password from Login where U_id =?");
stat.setString(1,t.getText());
res=stat.executeQuery();
if(!res.next())
{
l3.setText("invalid password");
}
else
l3.setText("Valid");
}

catch(Exception ex)
{
JOptionPane.showMessageDialog(null,"Could,nt retrive data :"+ex,"Error message",JOptionPane.ERROR_MESSAGE);
}
try{
c.close();
}
catch(Exception exp)
{
}

}
}

}
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31057
    
232

Ashok,
Welcome to JavaRanch!

What line throws the error?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 180

When i enter enter invalid username twice
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31057
    
232

Originally posted by Ashok Pradhan:
When i enter enter invalid username twice

I understand that. You are going to need to do a bit more debugging to get to a specific line of code though. You can either use a debugger or put in some System.out.printlns.
Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 180

I am using JCreater and TextPad,but how to use a debugger in both these text editors and Thanks.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31057
    
232

Originally posted by Ashok Pradhan:
I am using JCreater and TextPad,but how to use a debugger in both these text editors and Thanks.

I recommend posting a new question in the IDEs forum about how to debug using JCreator.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I got runtime error