I got the above error on the following code: Please help me. -
public void setCheckinDate(int reservationNumber)
-
throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException
-
{
-
Class.forName("com.mysql.jdbc.Driver").newInstance();
-
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/hrs","root","esubalew");
-
Statement st=con.createStatement();
-
Scanner in=new Scanner(System.in);
-
int year, month, day;
-
System.out.println(" Enter Checkin date(YYYY, MM, DD)");
-
System.out.println("======================================");
-
-
year=in.nextInt();
-
month=in.nextInt();
-
day=in.nextInt();
-
Date checkindate=new Date(year,month,day);
-
-
String update="update reservation set chckinDate="+checkindate+" where ReservNumber="+reservationNumber;
-
st.executeUpdate(update);
-
con.close();
-
}
the error is at the bold line. Date class is user defined. It works in other part of the program.
3 1888
The problem was at the following line. look it carafully. String update="update reservation set chckinDate='"+checkindate+" 'where ReservNumber="+reservationNumber;
Thank you, anyway!
Looks like checkindate is an object, not a variable. - Date checkindate=new Date(year,month,day);
So failing here - update="update reservation set chckinDate="+checkindate+"
But I am not sure about the Date class.
I got the above error on the following code: Please help me. -
public void setCheckinDate(int reservationNumber)
-
throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException
-
{
-
Class.forName("com.mysql.jdbc.Driver").newInstance();
-
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/hrs","root","esubalew");
-
Statement st=con.createStatement();
-
Scanner in=new Scanner(System.in);
-
int year, month, day;
-
System.out.println(" Enter Checkin date(YYYY, MM, DD)");
-
System.out.println("======================================");
-
-
year=in.nextInt();
-
month=in.nextInt();
-
day=in.nextInt();
-
Date checkindate=new Date(year,month,day);
-
-
String update="update reservation set chckinDate="+checkindate+" where ReservNumber="+reservationNumber;
-
st.executeUpdate(update);
-
con.close();
-
}
the error is at the bold line. Date class is user defined. It works in other part of the program.
Why are you using a user defined Date class?
What is the type of chckinDate in the database?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mark |
last post by:
good spam subject ;).
anyway, i'm alittle stumped. i'm in need of putting together a query
that gets the next highest salary ( select max ( sal ) - 1?, from an
emp_sal type table. another...
|
by: Justin Lebar |
last post by:
Sorry about the huge post, but I think this is the amount of
information necessary for someone to help me with a good answer.
I'm writing a statistical analysis program in ASP.net and MSSQL7 that...
|
by: theintrepidfox |
last post by:
Dear Group
Some but not all of the dates are incorrect converted (incremented by 1
day) with the following SQL statement.
SELECT DISTINCT CONVERT(datetime,cast(ReturnedByDate AS int)) AS...
|
by: bobdedogh |
last post by:
can anyone add live hyperlinks to the sortable table made by the code
supplied by Machi, or know of a simple alternative
bob
Machi wrote Mar 10 1999, 8:00 am
>>>>>>>>>>>>>>
....
Hello...
|
by: Dnna |
last post by:
I have a table which is bound to an Internet Explorer XML
data island. I'm using ASP.NET's client-side validators
for an input field in the table. The problem is that if
the input fields are in...
|
by: Nalaka |
last post by:
Hi,
I have two questions about gridViews.
1. How can I intercept the row/column values at loading to change values?
2. After I update a row (using default update functionality), how can I...
|
by: |
last post by:
Hello,
Does anyone have an idea on how I can filter the data in the gridview
control that was returned by an sql query?
I have a gridview that works fine when I populate it with data. Now I...
|
by: pbd22 |
last post by:
Hi.
Like the title says - how do i do this?
I was given the following example:
INSERT INTO TABLE2 SELECT * FROM TABLE1 WHERE COL1 = 'A'
The above statement threw the following error:
|
by: LucasLondon |
last post by:
Hi,
Sorry, this is a bit of a lengthy one but I guess too much information is better than less!
I have an excel worksheet that I update regulary with latest values from downloaded CSV files....
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |