My Sql Error

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 process
My 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 issue
MY 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 SQL
My SQL  Connection class for MySQL in java
SQL Error - SQL
SQL 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
SQL Error Version 5.5.15
SQL Error Version 5.5.15  SQL Error Version 5.5.15
my sql innodb
my 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 - JDBC
My 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 statement
error : 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 android
SQL 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 PROJECT
I 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 help
sql 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-Servlet
SQL 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 error
correct 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 Error
JSP 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 ERROR
SQL 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 advise
Syntax 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 - Hibernate
hibernate 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 sql
foreign 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
My SQL upgrade to version 5.5 issue
My SQL upgrade to version 5.5 issue  My SQL upgrade to version 5.5 issue
How to trap Trigger Error - SQL
How 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 code
i 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 code
i 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 Beginners
ERROR 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
Help on JDBC and my SQL 5 database - JDBC
Help on JDBC and my SQL 5 database  Dear Sir, I had create a statement for the JDBC as shown below: try{ Class.forName("com.mysql.jdbc.Driver"); // Establish
correct the sql error and retrive data....plez
correct 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 Java
Error 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 Java
Error 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 Beginners
syntax 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
how to call list objects as string into my sql query?
how to call list objects as string into my sql query?  how to call list data as string into my sql query so that i can retrieve all values from database? List has data retrieved from xml(using xmlSAXparser
Java servlet sql connectivity error - JSP-Servlet
Java 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
syntax error in SQL Insert Statement - Java Beginners
syntax error in SQL Insert Statement   private class ButtonListener implements ActionListener{ public void actionPerformed(ActionEvent ae){ //tab1 if(ae.getSource()==bt1ok){ // String date
how do i use sql like query in my jsp page
how 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
plz check my codings are correct or not...There is an error..i cant find it..
plz check my codings are correct or not...There is an error..i cant find it..  import java.util.Scanner; public class Student { private String indexNo; private String gender; private char initial; private int mark1
jquery dependency dropdown box in spring hibernate my sql
jquery dependency dropdown box in spring hibernate my sql  Hi Friends, Can you please provide me the code for dynamic drop down box using jquery in spring, hibernate and oracle/mysql database. Like if i select country
Java Compilation error - SQL
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
How to Import mysql database command line, Import MySQL dumpfile, SQL datafile into my database ?
How to Import mysql database command line, Import MySQL dumpfile, SQL datafile into my database ?  Import mysql database command line, Import MySQL dumpfile, SQL datafile into my database   You can easily restore
Can someone review my script for an apparent parsing error? -it isn't quite finished yet, but I want to fix error first
Can someone review my script for an apparent parsing error? -it isn't quite finished yet, but I want to fix error first   import java.util.Scanner; class historyquiz{ public static void main(String args
I'm getting an illgal start of expression error in my code for the public static boolean portion at the bottom... any ideas?
I'm getting an illgal start of expression error in my code for the public static boolean portion at the bottom... any ideas?  heres my code import java.util.Scanner; import java.util.Random; public class numberGame
need help....how to connect and disconnect multiple databases(databases created in mysql) using java and my sql
in mysql) using java and my sql  i am working on a project on deadlock in distributed transactions , and in that i am using my sql in java i need to know that how to query multiple databases(databases created in my mysql) so
confused about an error in my web application deploying to Tomcat - Java Server Faces Questions
confused about an error in my web application deploying to Tomcat  ... com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! Error at line 26 char 69: argument type mismatch... start SEVERE: Error listenerStart Jul 4, 2008 8:45:24 PM
how to insert multiple columns of a single row into my sql database using jsp
how to insert multiple columns of a single row into my sql database using jsp  hi sir, how to insert multiple columns of a single row into my sql database using jsp. when i click ADD ROW,rows are added.when i click submit
error
error  i have 404 error in my program plz tell me yhe solution about
error
error  i have 404 error in my program plz tell me yhe solution about
error
error  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
Error
Error  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
error
error  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
error
error

Ads