Help me....

gprsm

Honorable
May 28, 2012
4
0
10,510
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:eek: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....
 

gprsm

Honorable
May 28, 2012
4
0
10,510
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...........
 

randomizer

Distinguished


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.
 

smethrony

Honorable
May 15, 2012
3
0
10,510



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.