473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

database

how can i fetch date type of data from oracle database?
Mar 14 '12 #1
9 2314
r035198x
13,262 8TB
Same way you get other types.
Expand|Select|Wrap|Line Numbers
  1. select columnName from tableName
What problem are you getting exactly?
Mar 14 '12 #2
Actually i am entering date from keyboard and try to fetch it

String sql= "select * from LogTable3 where logDate="+date;

i am taking date as a user input, but its not working
Mar 14 '12 #3
r035198x
13,262 8TB
What programming language are you using and what type is that date variable that you adding to the query?
Mar 14 '12 #4
i am using java and date variable i am taking as Date object
Mar 14 '12 #5
r035198x
13,262 8TB
You need to brush up on your JDBC. You don't set date parameters like that. You set them on a PreparedStatement
Expand|Select|Wrap|Line Numbers
  1. String sql= "select * from LogTable3 where logDate=?";
  2. preparedStatement.setDate(1, date);
  3.  
Mar 14 '12 #6
i am setting it by using statement obj bro...
Mar 14 '12 #7
r035198x
13,262 8TB
I don't understand. You just said that you set it using

String sql= "select * from LogTable3 where logDate="+date;

above. That is not setting it using statement.
Mar 14 '12 #8
String date= "25-jun-2012";
Statement stmt1= connection.createStatement();
String sql= "select * from LogTable3 where logDate="+date;
ResultSet rs1= stmt1.executeQuery(sql);

now u understand or not?
Mar 14 '12 #9
r035198x
13,262 8TB
1.) You said "date variable i am taking as Date object ". But you have
Expand|Select|Wrap|Line Numbers
  1. String date= "25-jun-2012";
That is a string not a date.
2.) Don't ever use Statement. Use PreparedStatement instead because
a.)PreparedStatement will cache the compiled query on the database and so will be faster for multiple invocations
b.)PreparedStatement protects against SQL injection.
3.) You should create a java.sql.Date object to set as the parameter in your prepared statement. You change the String to a Date using the SimpleDateFormat class, something like
Expand|Select|Wrap|Line Numbers
  1. date = new SimpleDateFormat("MM-dd-yyyy").parse("25-06-2012");
  2. PreparedStatement ps = connection.prepareStatement(sql);        ps.setDate(1, new java.sql.Date(date.getTime()));       
  3.  
Mar 14 '12 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript and then I create a database user named setup. I...
0
by: Cherrish Vaidiyan | last post by:
sir, The following are the steps that i followed in setting up standby database on Red hat Linux 9. i am using Oracle 9i. i have followed the steps in this site : ...
6
by: Marvin Libson | last post by:
Hi All: I am running DB2 UDB V7.2 with FP11. Platform is Windows 2000. I have created a java UDF and trigger. When I update my database I get the following error: SQL1224N A database...
8
by: Kamlesh | last post by:
Hi, How do I know the physical database path of a database. When I goto the DB2INSTANCE users's directory (/home/db2inst1), I see following folders: /db2inst1/NODE0000/SQL00001...
1
by: pintur | last post by:
The message is: SQL1036C Errore di I/O durante l' accesso al database. SQLSTATE=58030 what is the proble? what for restore tables? thanks
3
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news...
0
by: Jack | last post by:
Training Classes for Oracle10g, 9i, 8i Certification training in Oracle10g and 9i: DBA, Developer, Discoverer. training conducted at your location worldwide. Courseware licensing also available....
0
by: Winder | last post by:
Training Classes for Oracle10g, 9i, 8i Certification training in Oracle10g and 9i: DBA, Developer, Discoverer. training conducted at your location worldwide. Courseware licensing also available....
0
by: Laurynn | last post by:
# (ebook - pdf) - programming - mysql - php database applicati # (Ebook - Pdf)Learnkey How To Design A Database - Sql And Crystal Report # (ebook-pdf) E F Codd - Extending the Database Relational...
9
by: Peter Duniho | last post by:
Is there a straightfoward API in .NET that allows for inspection of a database? That is, to look at the structure of the database, without knowing anything in advance about it? For example,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
0
isladogs
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.