import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
class MSaccess extends JFrame implements ActionListener
{

JLabel sno,sname,sadd;
JTextField t1,t2,t3;
JButton INSERT;
Connection con;
PreparedStatement ps;

MSaccess()
{

Container cp=getContentPane();
cp.setLayout(new FlowLayout());
cp.setSize(200,200);
//add the components
sno=new JLabel("sno");
cp.add(sno);
t1=new JTextField(10);
cp.add(t1);
sname=new JLabel("sname");
cp.add(sname);
t2=new JTextField(10);
cp.add(t2);
sadd=new JLabel("sadd");
cp.add(sadd);
t3=new JTextField(10);
cp.add(t3);
INSERT=new JButton("Insert");
INSERT.addActionListener(this);
cp.add(INSERT);
//create jdbc connection prepared statement
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbcdbcradsn");
//create prepared satement
ps=con.prepareStatement("insert into student(?,?,?)");

}
catch (Exception e)
{
e.printStackTrace();
}
}
public void actionPerformed(ActionEvent ae)
{
try
{
String sno=t1.getText();
String sname=t2.getText();
String sadd=t2.getText();
ps.setString(1,sno);
ps.setString(2,sname);
ps.setString(3,sadd);
int result=ps.executeUpdate();
if(result==0)
System.out.println("Records not inserted");
else
System.out.println("Records is inserted");


}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
ps.close();
con.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}

class MSaccess1

{
public static void main(String args[]) throws Exception
{
MSaccess ms=new MSaccess();
ms.show();


}
}









import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
class MSaccess extends JFrame implements ActionListener
{

JLabel sno,sname,sadd;
JTextField t1,t2,t3;
JButton INSERT;
Connection con;
PreparedStatement ps;

MSaccess()
{

Container cp=getContentPane();
cp.setLayout(new FlowLayout());
cp.setSize(200,200);
//add the components
sno=new JLabel("sno");
cp.add(sno);
t1=new JTextField(10);
cp.add(t1);
sname=new JLabel("sname");
cp.add(sname);
t2=new JTextField(10);
cp.add(t2);
sadd=new JLabel("sadd");
cp.add(sadd);
t3=new JTextField(10);
cp.add(t3);
INSERT=new JButton("Insert");
INSERT.addActionListener(this);
cp.add(INSERT);
//create jdbc connection prepared statement
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbcdbcradsn");
//create prepared satement
ps=con.prepareStatement("insert into student(?,?,?)");

}
catch (Exception e)
{
e.printStackTrace();
}
}
public void actionPerformed(ActionEvent ae)
{
try
{
String sno=t1.getText();
String sname=t2.getText();
String sadd=t2.getText();
ps.setString(1,sno);
ps.setString(2,sname);
ps.setString(3,sadd);
int result=ps.executeUpdate();
if(result==0)
System.out.println("Records not inserted");
else
System.out.println("Records is inserted");


}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
ps.close();
con.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}

class MSaccess1

{
public static void main(String args[]) throws Exception
{
MSaccess ms=new MSaccess();
ms.show();


}
}










D:\ms access>java MSaccess1
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax
INSERT INTO statement.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(Un known Sour
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpd ate(Unknow

at MSaccess.actionPerformed(MSaccess1.java:61)
at javax.swing.AbstractButton.fireActionPerformed(Unk nown Sourc
at javax.swing.AbstractButton$Handler.actionPerformed (Unknown S
at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown S
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unk
ce)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)




















D:\ms access>java MSaccess1
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax
INSERT INTO statement.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(Un known Sour
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpd ate(Unknow

at MSaccess.actionPerformed(MSaccess1.java:61)
at javax.swing.AbstractButton.fireActionPerformed(Unk nown Sourc
at javax.swing.AbstractButton$Handler.actionPerformed (Unknown S
at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown S
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unk
ce)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown So
at java.awt.LightweightDispatcher.processMouseEvent(U nknown Sou
at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Sou
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

















D:\ms access>java MSaccess1
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax
INSERT INTO statement.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(Un known Sour
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpd ate(Unknow

at MSaccess.actionPerformed(MSaccess1.java:61)
at javax.swing.AbstractButton.fireActionPerformed(Unk nown Sourc
at javax.swing.AbstractButton$Handler.actionPerformed (Unknown S
at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown S
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unk
ce)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown So
at java.awt.LightweightDispatcher.processMouseEvent(U nknown Sou
at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Sou
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

















D:\ms access>java MSaccess1
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax
INSERT INTO statement.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(Un known Sour
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpd ate(Unknow

at MSaccess.actionPerformed(MSaccess1.java:61)
at javax.swing.AbstractButton.fireActionPerformed(Unk nown Sourc
at javax.swing.AbstractButton$Handler.actionPerformed (Unknown S
at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown S
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unk
ce)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown So
at java.awt.LightweightDispatcher.processMouseEvent(U nknown Sou
at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Sou
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

















D:\ms access>java MSaccess1
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax
INSERT INTO statement.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(Un known Sour
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpd ate(Unknow

at MSaccess.actionPerformed(MSaccess1.java:61)
at javax.swing.AbstractButton.fireActionPerformed(Unk nown Sourc
at javax.swing.AbstractButton$Handler.actionPerformed (Unknown S
at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown S
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unk
ce)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown So
at java.awt.LightweightDispatcher.processMouseEvent(U nknown Sou
at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Sou
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)