Sign in with
Sign up | Sign in
Your question

Help me....

Last response: in Applications
Share
June 2, 2012 5:52:40 AM

Hello, frnz...
my application is a jdbc program which has the code as follows...

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class test extends JApplet implements ActionListener,ItemListener
{
JLabel l1,l2;
JTextField t1;
JButton save;
JPanel p1,p2;
Container cp=getContentPane();
JCheckBox cb[];
String sel=" ";
public void init()
{
cp.setLayout(new FlowLayout());
t1=new JTextField(10);
l1=new JLabel("enter name");
p1=new JPanel();
p1.add(l1);
p1.add(t1);
p2=new JPanel();
l2=new JLabel("Select your Occupation");
p2.add(l2);
cb=new JCheckBox[3];
for(int i=1;i<4;i )
{
c=new JCheckBox();
p2.add(c);
c.addItemListener(this);
}
cb[0].setText("ONE");
cb[1].setText("TWO");
cb[2].setText("THREE");
save=new JButton("SAVE");
p2.add(save);
save.addActionListener(this);
cp.add(p1);
cp.add(p2);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==save)
{
String name=t1.getText();
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{
System.out.println("Class Exception occured");
}
try
{
Connection con=DriverManager.getConnection("jdbc:o dbc:mvgr","system","management");
Statement s=con.createStatement();
String query="Insert into abc values(name " " sel )";---error
int c=s.executeUpdate(query);
System.out.println(c "rows inserted");
}
catch(SQLException e)
{
System.out.println("Exception occured");
}
}
public void itemStateChanged(ItemEvent i)-- error
{
//if(i.getStateChange()==ItemEvent.SELECTED)
sel=sel ((JCheckBox)(i.getItemSelectable())).getText();
}
}
}

when i compiled the program.....
iam getting 1 error at "query initialization" and 4 errors at the method "itemstatechanged()"....
here the thing which let us to confusion state is the error--- " ; expected " at the end of above statements
i found no solution for this...
iam xpctng ur response regerding my program....plz help me....

More about : question

June 2, 2012 6:23:52 AM

Hai frnz.......
iam going to design a front end application with java (using applets and swings).
as it is quite complex to design the home page with java applets, i have chosen html.
but here comes the problem that,
how to link my html page with java applets????
i found two solutions for this....
1.making the use of <codebase> tag along with the URL of java applet
2.making the use of <params> tag in html program and extracting the parameter values in the java applet program(at init() method),which reside at the same directory....

my problem is what to use now???
which of them is easier to get my job done efficiently.......

can someone help me plzzzzzzzzz...........
m
0
l
June 2, 2012 10:00:32 AM

This next topics has been merged by Mousemonkey
  • Help me plz...
    m
    0
    l
    Related resources
    a b L Programming
    June 2, 2012 10:27:30 AM

    gprsm said:
    String query="Insert into abc values(name " " sel )";---error


    This line is badly formed. You have two strings separated by a space, and the compiler has no idea what you are trying to do. It's assuming that the statement is supposed to end after the first string, which is why it's expecting a semicolon. The second string is not being assigned to anything or used in any way, it's just there. Now if you concatenated the two strings then the compiler wouldn't be complaining, because that would be a valid statement. You're not concatenating anything though.

    Perhaps some of the characters were just stripped out when you posted this, and I'm pointing out a problem that is not actually in your code. Next time wrap your code in [ code ] [ /code ] (without spaces inside the brackets) tags, as this will preserve formatting and everything.

    On a side note: Your variable names are terrible.
    m
    0
    l
    June 2, 2012 10:47:22 AM

    oh.....thnx for the suggestion.........
    i did it sir.......the trick worked well..........
    thnx alot!!!!!!!!!!!
    m
    0
    l
    June 2, 2012 4:09:05 PM

    gprsm said:
    Hai frnz.......
    iam going to design a front end application with java (using applets and swings).
    as it is quite complex to design the home page with java applets, i have chosen html.
    but here comes the problem that,
    how to link my html page with java applets????
    i found two solutions for this....
    1.making the use of <codebase> tag along with the URL of java applet
    2.making the use of <params> tag in html program and extracting the parameter values in the java applet program(at init() method),which reside at the same directory....

    my problem is what to use now???
    which of them is easier to get my job done efficiently.......

    can someone help me plzzzzzzzzz...........



    It is so easy that first you can use javascript to manipulate the html page as usual.May also need to include the mayscript parameter when declaring the applet, not sure if this is needed anymore or not.
    m
    0
    l
    !