sushant
My Sql Error
3 Answer(s)      3 years and 5 months ago
Posted in : Development process

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 Pages:
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
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
My SQL
My SQL  Connection class for MySQL in java
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
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
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
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
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
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
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
SQL
SQL  In my computer i have microsoft sql 2008.how can i set that in the cmd.i want to use that in cmd.what is the default username and password
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 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
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
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
sql
sql  i need a query for selecting values from a table till a certain date...my database has date in the format '01-JAN-01 12.00.00.000000000 AM
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
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
sql
sql  i want that whenever i click add button in my form value of an column employee-id will automatically increase by one..and show the new employee-id value in text box. please send me the source code for this .   
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
error
"+it); } } this is my program i am getting an error saying cannot find symbol class string
error
is"+sum); } } this is my program i need to print the series (1+2/12)+(1+2
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
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
connection error - WebSevices
connection error   while conncting a tool(jet profiler for my sql 1.0 released) with my running application ,it reflects following error: connected,but failed to login,read time out
SQL exception, Exhausted ResultSet
SQL exception, Exhausted ResultSet  javax.servlet.ServletException: java.sql.SQLException: Exhausted Resultset iam getting this error messege whenever i run my code. what would be the possible reasons
my answer
my answer  import com.mysql.jdbc.Connection; import...-specific error occurs * @throws IOException if an I/O error occurs */ protected... ServletException if a servlet-specific error occurs * @throws IOException if an I/O
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
sql - SQL
sql  my requirement is to show a record for two hours(match time) from its start time, i have match start time , i am using this but its not wot i want ,ie match_DateTime between DATEADD(DAY,-1,DATEDIFF(DAY,0,CURRENT_TIMESTAMP
SQL - SQL
combobox Can u please tell me how to do it i tried but it is giving me error
error message - JSP-Servlet
error message  hi, friends after complete my servlet programe i... device, path, or file you may not have the appropriate permission to access". my sql+ is not working ,so what is the solution.plez any body give me the replay
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
MySql function - SQL
, but it is stating that 'You have an error in SQL systax; check the manual.... Please check my code and let me inform what mistake i did. Your help is appreciated well in advance. Thank you, The SQL code is as follows
What's wrong with my pagination code in JSP?
What's wrong with my pagination code in JSP?  Dear experts, I've... whatever lines that NetBean IDE has given me error signal. The resulted page... query1="SELECT SQL_CALC_FOUND_ROWS * FROM db2admin.reg limit "+iPageNo
my question is related to my project viz
my question is related to my project viz   Sir, my project is based on MR tracking system developed using struts framework, it has been developed... the browser is showing "No Such Class Found Error" im unable to sort out the error
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: <%@ page import="java.sql.*"%> <% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver
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
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
Java to SQL Server Connectivity
Java to SQL Server Connectivity  Hi, heres my code private void... Seat is Available or Not","Error", JOptionPane.ERROR_MESSAGE... with sql server connectivity at the background to save the data. Now, after
large resultset values - SQL
the details i'm getting error like.... Please help me To avoid such problems as becoz my project is about to deliver
loop error - Ajax
loop error  Expert:ARIJEET sory....dude....it's not my perfect...: http://www.roseindia.net/sql/mysql-example/pagination.shtml Hope that it will be helpful for you. Thanks but it's not my prfect solution..... i
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
Java and SQL - SQL
Java and SQL  i have a problem with regard to connecting my java code in getting a data to SQL. my problem is on how to come up with a pop up alert message in the user interface where in the message will be coming from the SQL
Logic error? HELP PLEASE! :(
Logic error? HELP PLEASE! :(  Hello Guys! i have a huge problem. What... info using its date and email together. However if I don key in my email the page forward to the result page then all is display as null. But if I key in my
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.