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.Simpl eDateFormat df = new java.text.Simpl eDateFormat("DD/MM/yy");
String s = "01/02/99";
java.util.Date utilDate = df.parse(s);
sqlDate = new java.sql.Date(u tilDate.getTime ());
System.out.prin tln("SQL Date" +sqlDate); //1999-01-01
}
catch(ParseExce ption p)
{
p.printStackTra ce();
}
select = conn.createStat ement(ResultSet .TYPE_SCROLL_SE NSITIVE,ResultS et.CONCUR_UPDAT ABLE);
System.out.prin tln("In InsertRecord method");
// String updateStatement = "insert into video values (" +"'" + vid + "'," +"'" + title + "'," + "'" + type + "','" +sqlDate +"'," + vcharge +")";
int x = select.executeU pdate("INSERT INTO Video " + "VALUES ('M0009', 'Pokemon','U', 'sqlDate', 3.00)" );
System.out.prin tln(x + " rows affected");
[code]
5 5185
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.Simpl eDateFormat df = new java.text.Simpl eDateFormat("DD/MM/yy");
String s = "01/02/99";
java.util.Date utilDate = df.parse(s);
sqlDate = new java.sql.Date(u tilDate.getTime ());
System.out.prin tln("SQL Date" +sqlDate); //1999-01-01
}
catch(ParseExce ption p)
{
p.printStackTra ce();
}
select = conn.createStat ement(ResultSet .TYPE_SCROLL_SE NSITIVE,ResultS et.CONCUR_UPDAT ABLE);
System.out.prin tln("In InsertRecord method");
// String updateStatement = "insert into video values (" +"'" + vid + "'," +"'" + title + "'," + "'" + type + "','" +sqlDate +"'," + vcharge +")";
int x = select.executeU pdate("INSERT INTO Video " + "VALUES ('M0009', 'Pokemon','U', 'sqlDate', 3.00)" );
System.out.prin tln(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.executeU pdate("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.executeU pdate("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 oracle.sql.NUMBER._fromLnxFmt(NUMBER.java:3181)
at oracle.sql.NUMBER.toBigDecimal(NUMBER.java:636)
at oracle.jdbc.dbaccess.DBConversion.NumberBytesToBigDecimal(DBConversio
n.java:2805)
at oracle.jdbc.driver.OracleStatement.getBigDecimalValue(OracleStatement
..java:4539)
|
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 from
outside (using the oracle THIN driver)
can anyone tell me what is the problem and how to solve it?
thanks
|
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 in advance
|
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 all the relevant files under the folder C:\oracle\ora92\jdbc\lib
Initially I had JDK 6 downloaded from Sun's website, but I didn't think it would be compatible with the older database, so I then replaced that with SDK 1.4.
| |
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
resultSet.getDate(paramIndex)
and it's giving me a date that's way off.
|
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 easiest method to add the current date/time (dd/mm/yy hh:mm:ss) via JDBC in DATE format i.e. convert STRING to DATE or format the DATE without changing its type and insert it.
I'm a newbie to Java/Jsp too.
|
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 your commit is coming from.
Jim
--
Replace part of the email address: kennedy-down_with_spammers@attbi.com
with family. Remove the negative part, keep the minus sign. You can figure
it out.
|
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 file.
Regards
/Rauf
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |