My Sql Error
View Answers
December 23, 2009 at 11:58 AM
Hi Friend,
We have taken all the fields as "Text" in the database.
Try the following code:
import java.io.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
class Project{
JFrame f;
JPanel p1,p2,p3,p4,p;
JTabbedPane tp;
JLabel l1, l2, l3, l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16,l17,l18,l19,l20;
JTextField tf1,tf2,tf3,tf4,tf5,tf6,tf7,tf8,tf9,tf10,tf11,tf12;
JScrollPane sp1;
JButton savebtn,resetbtn,searchbtn,editbtn1,editbtn2,delbtn,btn ;
Project(){
f=new JFrame("Bus TimeTable");
p=new JPanel();
p1=new JPanel(new GridLayout(6,2));
p2=new JPanel(new GridLayout(6,2));
p3=new JPanel(new GridLayout(6,2));
p4=new JPanel(new GridLayout(2,2));
tp=new JTabbedPane();
l1=new JLabel("Bus No:");
l2=new JLabel("Source:");
l3=new JLabel("Time(hh:mm:ss):");
l4=new JLabel("Destination:");
l5=new JLabel("Time(hh:mm:ss):");
l6=new JLabel("Enter bus no:");
l7=new JLabel("Bus No:");
l8=new JLabel("Source:");
l9=new JLabel("Time(hh:mm:ss):");
l10=new JLabel("Destination:");
l11=new JLabel("Time(hh:mm:ss):");
l12=new JLabel("Enter Bus No:");
l13=new JLabel("Source");
l14=new JLabel();
l15=new JLabel("Time(hh:mm:ss)");
l16=new JLabel();
l17=new JLabel("Destination");
l18=new JLabel();
l19=new JLabel("Time(hh:mm:ss)");
l20=new JLabel();
tf1=new JTextField(12);
tf2=new JTextField(12);
tf3=new JTextField(12);
tf4=new JTextField(12);
tf5=new JTextField(12);
tf6=new JTextField(12);
tf7=new JTextField(12);
tf8=new JTextField(12);
tf9=new JTextField(12);
tf10=new JTextField(12);
tf11=new JTextField(12);
tf12=new JTextField(12);
savebtn=new JButton(" Save ");
resetbtn=new JButton(" Reset");
searchbtn=new JButton("Search");
editbtn1=new JButton(" Edit ");
editbtn2=new JButton(" Save");
delbtn=new JButton(" Delete");
btn=new JButton("Back");
p1.add(l1);
p1.add(tf1);
p1.add(l2);
p1.add(tf2);
p1.add(l3);
p1.add(tf3);
p1.add(l4);
p1.add(tf4);
p1.add(l5);
p1.add(tf5);
p1.add(savebtn);
p1.add(resetbtn);
p2.add(l13);
p2.add(l14);
p2.add(l15);
p2.add(l16);
p2.add(l17);
p2.add(l18);
p2.add(l19);
p2.add(l20);
p2.add(l6);
p2.add(tf6);
p2.add(searchbtn);
p2.add(btn);
p3.add(l7);
p3.add(tf7);
p3.add(l8);
p3.add(tf8);
p3.add(l9);
p3.add(tf9);
p3.add(l10);
p3.add(tf10);
p3.add(l11);
p3.add(tf11);
p3.add(editbtn1);
p3.add(editbtn2);
p4.add(l12);
p4.add(tf12);
p4.add(delbtn);
p.add(p4);
l13.setVisible(false);
l14.setVisible(false);
l15.setVisible(false);
l16.setVisible(false);
l17.setVisible(false);
l18.setVisible(false);
l19.setVisible(false);
l20.setVisible(false);
btn.setVisible(false);
December 23, 2009 at 11:59 AM
continue..
resetbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
tf1.setText("");
tf2.setText("");
tf3.setText("");
tf4.setText("");
tf5.setText("");
}
});
savebtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
try{
String v1=tf1.getText();
String v2=tf2.getText();
String v3=tf3.getText();
String v4=tf4.getText();
String v5=tf5.getText();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:access","","");
Statement st=con.createStatement();
int i=st.executeUpdate("insert into timetable(busno,source,time1,destination,time2)values('"+v1+"','"+v2+"','"+v3+"','"+v4+"','"+v5+"')");
JOptionPane.showMessageDialog(p1," Submit Successfully... ");
}
catch(Exception exp1){
JOptionPane.showMessageDialog(p1," Submit Failed... ");
}
}
});
searchbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
l13.setVisible(true);
l14.setVisible(true);
l15.setVisible(true);
l16.setVisible(true);
l17.setVisible(true);
l18.setVisible(true);
l19.setVisible(true);
l20.setVisible(true);
btn.setVisible(true);
l6.setVisible(false);
tf6.setVisible(false);
searchbtn.setVisible(false);
try
{
String v=tf6.getText();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:access","","");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from timetable where busno='"+v+"'");
rs.next();
l14.setText(rs.getString("source"));
l16.setText(rs.getString("time1"));
l18.setText(rs.getString("destination"));
l20.setText(rs.getString("time2"));
}
catch(Exception exp3)
{
JOptionPane.showMessageDialog(p2,"Can't Search may be you have entered an invalid Bus Code");
}
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
l13.setVisible(false);
l14.setVisible(false);
l15.setVisible(false);
l16.setVisible(false);
l17.setVisible(false);
l18.setVisible(false);
l19.setVisible(false);
l20.setVisible(false);
btn.setVisible(false);
l6.setVisible(true);
tf6.setVisible(true);
searchbtn.setVisible(true);
}
});
}
});
December 23, 2009 at 11:59 AM
continue..
editbtn1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
try{
String v=tf7.getText();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:access","","");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from timetable where busno='"+v+"'");
String st1="",st2="",st3="",st4="";
while(rs.next()){
st1=rs.getString("source");
st2=rs.getString("time1");
st3=rs.getString("destination");
st4=rs.getString("time2");
}
tf8.setText(st1);
tf9.setText(st2);
tf10.setText(st3);
tf11.setText(st4);
}
catch(Exception exp4)
{
JOptionPane.showMessageDialog(p3,"Can not edit data...");
}
}
});
editbtn2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
try
{
int x=JOptionPane.showConfirmDialog(p3,"Confirm edit? All data will be replaced");
if(x==0)
{
try{
String v1=tf7.getText();
String v2=tf8.getText();
String v3=tf9.getText();
String v4=tf10.getText();
String v5=tf11.getText();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:access","","");
Statement st=con.createStatement();
st.executeUpdate("update timetable set source='"+v2+"', time1='"+v3+"', destination='"+v4+"', time2='"+v5+"' where busno='"+v1+"'");
JOptionPane.showMessageDialog(p3,"Saved........");
con.close();
}
catch(Exception exp5)
{
JOptionPane.showMessageDialog(p3,"Problem in updating edit fields...");
}
}
else if(x==1)
{
JOptionPane.showMessageDialog(p3,"Action terminated by user...");
}
else if(x==2)
{
tf7.setText("");
tf8.setText("");
tf9.setText("");
tf10.setText("");
tf11.setText("");
}
}
catch(Exception exp6)
{
JOptionPane.showMessageDialog(p3,"Error Code 6 : Editing Failed... ");
}
}
});
delbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String v=tf12.getText();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =DriverManager.getConnection("jdbc:odbc:access","","");
Statement st=con.createStatement();
int i=st.executeUpdate("Delete from timetable where busno='"+v+"'");
JOptionPane.showMessageDialog(p4,"Information is successfully deleted.");
}
catch(Exception e){
JOptionPane.showMessageDialog(p4,"Error in deleting data");
}
}
});
}
void dis()
{
f.getContentPane().add(tp);
tp.addTab("Add Details",p1);
tp.addTab("Search Options",p2);
tp.addTab("Edit Options",p3);
tp.addTab("Delete Options",p);
f.setSize(500,200);
f.setVisible(true);
f.setResizable(true);
}
public static void main(String z[])
{
Project pro=new Project();
pro.dis();
}
}
Thanks
Related Tutorials/Questions & Answers:
My Sql Error - Development processMy Sql Error Hello Sir ,I have Created Table with following Query,then Table Created Succefully,But some errors Occured,
can u give me the Code...,Its Very Very Urgent.
Thank u very Much for urs Great Support in
My MY Sql Query Error - Not able to Understand the issueMY Sql Query
Error - Not able to Understand the issue I am new... END
I am getting an
error as follow:
Schema Creation Failed: You have an
error in your
SQL syntax; check the manual that corresponds to your MySQL server
Advertisements
My SQLMy SQL Connection class for MySQL in java
SQL Error - SQLSQL Error Invalid character value for cast specification on column number 5 (Designation)
Whats this
error about this if the field i specified in programming
error.
ie DB fields in above question
my sql innodbmy sql innodb Write a java program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL
My sql - JDBCMy sql hi,
I have a table in MySql, having fields, emp_id,emp_name,emp_vertical,emp_supervisor.
i need a JDBC program with driver mangager for MySQL, statements, preparedstatements,resultset. Please can you suggest me a way
error : not an sql expression statementerror : not an
sql expression statement hii I am gettin followin
error in connecting to database SQLserver 2005 in Jdeveloper,i m usin struts and jsp
my pogram:
import java.sql.*;
public class TaskBO
{
public TaskBO
SQL connection error in androidSQL connection
error in android hi,
i am android developer . recently i made one application connect with
sql server 2005 using jtds...:
sql:Exception : BUFFERDIR connection property invalid.
if you have any answer
I GOT ERROR FOR MY PROJECTI GOT
ERROR FOR
MY PROJECT Dear Friend/ RoseIndia Team,
Firstly I would to thank u Guys help me so many time..
I got
error on
my little project when running at server.
please correctly
my error Guys...
ERROR CODE:
"LOGIN
sql syntax error helpsql syntax
error help this query show syntax
error .. i am unable to figure it out
insert into order
(orderdate, dpname, paymethod, tamount...')
where is the
error ?
Please send the
error details and the datatype
SQL error - JSP-ServletSQL error Hello friends,
Can we update a column... is the value to be replaced. This modification is neccesary one for
my project...){
System.out.println("
Error occured while updating!!!");
}
con.close
correct the sql errorcorrect the
sql error i am getting a
SQL Error while retriving data from access to jframe called "datatype mismatch in criteria expression" plez do...(null,"Please enter the Student ID to Search","
Error",0);
}
else
{
try
JSP SQL ErrorJSP
SQL Error Hi While trying to execute the below code i'm getting the following
error "java.sql.SQLException: Io exception: Got minus one from a read call ". please help me out.
<%
try{
String Username
SQL QUERY ERRORSQL QUERY ERROR Im writing a query which shows
error of INVALID... THE FORM IS THROWING THE
ERROR OF INVALID CHARACTER BUT THE SAME QUERY IS RUNNING..._value'. . .);
For more information, visit the following link:
SQL Queries
Syntax error in my UPDATE..please adviseSyntax
error in
my UPDATE..please advise Hi experts,
I tested
my...)
And here's
my UPDATE Statement:
String
sql = "UPDATE members SET strNRICNO...;
stmt.executeUpdate(
sql);
Please advise how should I change
my SQL to use Heidi MySQL
hibernate sql error - Hibernatehibernate
sql error Hibernate: insert into EMPLOYE1 (firstName, lastName, age, p-type, EMP_ID) values (?, ?, ?, 'e', ?)
Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
foreign key error in sqlforeign key
error in sql create table matchdetails(mid varchar2(10),mdate date,team1 varchar2(10),team2 varchar2(10...) references matchdetails(mid));
->for the above batsman table it shows
error How to trap Trigger Error - SQLHow to trap Trigger Error Hi Guys,
Can you please help with
my problem?..
Is there a way in where I can trap all
SQL error and place it under...
error_log (
timestamp DATETIME,
username NVARCHAR(30
i am unable to identify the error in my codei am unable to identify the
error in
my code class Program
{
public static void main(String[] args)
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter
i am unable to identify the error in my codei am unable to identify the
error in
my code class Program
{
public static void main(String[] args)
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter
ERROR with my JAVA code - Java BeginnersERROR with
my JAVA code The
error came up in
my main method... it wasnt there until i finished
my actionListener coding so I dont know how to fix this....it is really stressing me out!! HELP!!!
import java.awt.*;
import
correct the sql error and retrive data....plezcorrect the
sql error and retrive data....plez i am getting a
SQL Error while retriving data from access to jframe called "datatype mismatch...(""))
{
JOptionPane.showMessageDialog(null,"Please enter the Student ID to Search","
Error",0
Error while SQL Server connection to JavaError while
SQL Server connection to Java import java.sql.*;
public...");
con=DriverManager.getConnection("jdbc:odbc:
SQL_SERVER;user=DTHOTA;password...("password", " ");
con=DriverManager.getConnection("jdbc:odbc:
SQL_SERVER", prop
Error while SQL Server connection to JavaError while
SQL Server connection to Java import java.sql.*;
public...");
con=DriverManager.getConnection("jdbc:odbc:
SQL_SERVER;user=DTHOTA;password...("password", " ");
con=DriverManager.getConnection("jdbc:odbc:
SQL_SERVER", prop
syntax error in SQL Insert Statement - Java Beginnerssyntax
error in
SQL Insert Statement Dear Sir ,I have write following code to save data into access databse,
but code gives following
error
code...)values(?,?)");
Error:
java.sql.SQLException: [Microsoft][ODBC Microsoft
Java servlet sql connectivity error - JSP-ServletJava servlet
sql connectivity error Hi,
I have been trying to connect to
sql database via the servlet program in java.I have not been successful so far. However when i try to connect to
sql through a normal java program
how do i use sql like query in my jsp pagehow do i use
sql like query in
my jsp page how do i use
sql like query in
my jsp page
Hi Friend,
Try the following code:ADS_TO_REPLACE_1
<%@ page import="java.sql.*"%>
<%
Class.forName
error/ServletUserEnquiryForm.shtml
getting an
error given below
SQLException caught: [Microsoft][ODBC
SQL Server Driver]COUNT field incorrect or syntax
error
please suggest...error I am running a program insert into statement in
sql using
errorerror i have 404
error in
my program plz tell me yhe solution about
errorerror i have 404
error in
my program plz tell me yhe solution about
errorerror while iam compiling iam getting expected
error Error- Error- Hello, I would like to know about XSD file.
I try to print XML file but I am getting
error SAXException-- says
Content is not allowed in prolog.
Please help me
error"+it);
}
}
this is
my program i am getting an
error saying cannot find symbol class stringADS
ErrorError I have created ajax with php for state and city. When I change state then city will not come in dropdown list and it give me
error as 'Unknown Runtime
Error'.
This
error come only in IE browser, but in other brower
errorerror java.lang.unsupportedclassversionerror:bad major version at offset 6
how to solve this????
Hi,
Please check the version of framework used and also the JDK version.ADS_TO_REPLACE_1
This type
error also comes