I am trying to convert a date from string format into the SQL date format. This seems to work fine as it prints out as 1999-01-01 - see code below. I then try to insert this as a variable into my table and I get the error:
ORA-01858: a non-numeric character found where a digit was expected.
Any help would be greatly appreciated
[code]
try
{
java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("DD/MM/yy");
String s = "01/02/99";
java.util.Date utilDate = df.parse(s);
sqlDate = new java.sql.Date(utilDate.getTime());
System.out.println("SQL Date" +sqlDate); //1999-01-01
}
catch(ParseException p)
{
p.printStackTrace();
}
select = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITI VE,ResultSet.CONCUR_UPDATABLE);
System.out.println("In InsertRecord method");
// String updateStatement = "insert into video values (" +"'" + vid + "'," +"'" + title + "'," + "'" + type + "','" +sqlDate +"'," + vcharge +")";
int x = select.executeUpdate("INSERT INTO Video " + "VALUES ('M0009', 'Pokemon','U', 'sqlDate', 3.00)" );
System.out.println(x + " rows affected");
[code]
5 5178
I am trying to convert a date from string format into the SQL date format. This seems to work fine as it prints out as 1999-01-01 - see code below. I then try to insert this as a variable into my table and I get the error:
ORA-01858: a non-numeric character found where a digit was expected.
Any help would be greatly appreciated
[code]
try
{
java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("DD/MM/yy");
String s = "01/02/99";
java.util.Date utilDate = df.parse(s);
sqlDate = new java.sql.Date(utilDate.getTime());
System.out.println("SQL Date" +sqlDate); //1999-01-01
}
catch(ParseException p)
{
p.printStackTrace();
}
select = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITI VE,ResultSet.CONCUR_UPDATABLE);
System.out.println("In InsertRecord method");
// String updateStatement = "insert into video values (" +"'" + vid + "'," +"'" + title + "'," + "'" + type + "','" +sqlDate +"'," + vcharge +")";
int x = select.executeUpdate("INSERT INTO Video " + "VALUES ('M0009', 'Pokemon','U', 'sqlDate', 3.00)" );
System.out.println(x + " rows affected");
[code]
What are the data types of your table in the database and what values are you trying to insert into that table.
What are the data types of your table in the database and what values are you trying to insert into that table.
The datatypes of my table are VARCHAR2, VARCHAR2, VARCHAR2, DATE, NUMBER. I am entering data values from my Swing interface using 5 textfields.
Thanks
The datatypes of my table are VARCHAR2, VARCHAR2, VARCHAR2, DATE, NUMBER. I am entering data values from my Swing interface using 5 textfields.
Thanks
Now post the exact sql statement that is giving you the error.
Now post the exact sql statement that is giving you the error.
The following line in my java program compiles fine but the insert of the date into the table is giving me the error.
[code] int x = select.executeUpdate("INSERT INTO Video " + "VALUES ('M0009', 'Pokemon','U', 'sqlDate', 3.00)" ); [code]
You will see from my earlier code that I have converted the date from a string into the sqlDate format. My problem is that when I print it out to the console after the conversion it looks like 1999-01-01 but oracle is trying to store it as 01-JAN-99.
I am now trying to use TO_DATE(sqlDate, "DD-MON-YY) but I dont know how to put this in as a parameter into the executeUpdate() method. It's giving me an "unclosed character literal error".
Thanks.
The following line in my java program compiles fine but the insert of the date into the table is giving me the error.
[code] int x = select.executeUpdate("INSERT INTO Video " + "VALUES ('M0009', 'Pokemon','U', 'sqlDate', 3.00)" ); [code]
You will see from my earlier code that I have converted the date from a string into the sqlDate format. My problem is that when I print it out to the console after the conversion it looks like 1999-01-01 but oracle is trying to store it as 01-JAN-99.
I am now trying to use TO_DATE(sqlDate, "DD-MON-YY) but I dont know how to put this in as a parameter into the executeUpdate() method. It's giving me an "unclosed character literal error".
Thanks.
I don't think it's the date that's giving you problems. I think it's the last field but you are supplying 3.00 which must be accepted unless if that field is taking integers only. Did you try 3 instead of 3.00?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Rahul |
last post by:
I am getting the following exception when accessing one of my tables.
java.lang.reflect.InvocationTargetException:
java.lang.ArrayIndexOutOfBoundsException
at...
|
by: hilz |
last post by:
Hi all:
I have an oracle 9i server running behind a firewall.
i set up the machine that has the oracle server as a DMZ zone.
i can connect to the oracle server from the local network but not...
|
by: CM |
last post by:
Hi,
when i want connect me in my BD with a JSP (with this simple code),
this exception is throw.
Thank's for ur help
Mathieu
CODE of my JSP
---------------------
|
by: Kona |
last post by:
Hello,
I'm new with Oracle JDBC connection.
Is it a way to crypt, hide the password string into a Oracle JDBC
connection string ?
The goal is to hide the password within script file.
Thank's...
|
by: owen |
last post by:
Hi,
I've been trying for ages to connect to my Oracle 9.2.0 database from Java.
I am attempting to create a thin connection.
The necessary drivers were installed with the database and I have...
| |
by: Kenevel |
last post by:
Hi everyone,
Has anyone come across a problem where on Linux using DB2 9.1 Express-
C with the packaged jcc-JDBC driver that it fails correctly to parse a
returned date value? I'm simply calling...
|
by: robtyketto |
last post by:
Greetings,
I have the following code below which allows the date to be added via a JDBC connection as a STRING.
The value of dateString is inserted into the MS ACCESS database.
What is the...
|
by: Jim Kennedy |
last post by:
ALL DDL does a commit. Hence Drop Table movies; issues a commit. True you
don't issue a commit and the driver does not issue a commit, but the server
does for all DDL.
That is probably where...
|
by: Rauf Sarwar |
last post by:
Originally posted by Nelson Broat
Have you included Oracle jdbc driver in your classpath? Depending on
your Oracle version, it would be ORACLE_HOME/jdbc/lib/classesXXX.zip or
classesXXX.jar...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |