Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   code compilation problem,please help (http://www.go4expert.com/forums/code-compilation-problemplease-help-t12059/)

rosesinspring 12Jul2008 21:49

code compilation problem,please help
 
Code:

import java.awt.*;
import java.sql.*;
import java.awt.event.*;
public class pubinfo implements ActionListener
{
Label lpubid;
TextField pub_id;
Button insert;
Panel p1;
Frame f1;
 Connection con;
PreparedStatement stat;
Statement stmt;
ResultSet rs;
public pubinfo()
{
try
{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
String url = "jdbc:odbc:+Library";
Connection db_connection = DriverManager.getConnection (url, "sa", "friendship");
Statement stmt = db_connection.createStatement();
}
catch (ClassNotFoundException cnfe)
{
        System.err.println ("Unable to load database driver");
        System.err.println ("Details : " + cnfe);
        System.exit(0);
}
}
public void display()
{
f1 =new Frame("pubinfo");
p1 =new  Panel();
lpubid =new Label("Login");
pub_id=new TextField(6);
insert =new Button("ok");

lpubid.setBounds(250,35,200,40);
pub_id.setBounds(100,90,100,25);
p1.add(lpubid);
p1.add(pub_id);

insert.addActionListener(this);
}


public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand() == "ok")
{
try
{
stat=con.prepareStatement("INSERT INTO pubinfo VALUES(?)");
String pid=pub_id.getText();
stat.setString(1,pid);
stat.executeUpdate();
pub_id.setText(" ");
}

catch(Exception e)
{
System.out.println(" Error1:" +e);
error.SetText("row not inserted");
}
}
}

public static void main(String args[])
{
pubinfo p= new pubinfo();
p.display();

}
}


shabbir 12Jul2008 22:30

Re: code compilation problem,please help
 
You had the same thread twice and both the time you had it in the wrong forum and as of now I have moved both to Java forum and closed the other thread.,

rosesinspring 13Jul2008 04:06

Re: im sorry
 
im really sorry..but please excuse me as im new to this site..and i hope to get an answer to my query in java :worried:


All times are GMT +5.5. The time now is 04:19.