473,387 Members | 3,684 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,387 software developers and data experts.

Conversion of data type from MySql to JSP

58
My proj involves JSP @ front end n MySql @ back end and connectivity is established thru JDBC. The thing is when i store values from the front end into the db i need to change the data types n vice versa.Consider ths.

I m retrieving date from the db thru the result set i m traversing thru each n every record(next() function is used).

String d1 = rs.getString(2);System.out.println("Date="+date);

How do i convert the date field into a java.sq.Date value such dat it can be retrieved back @ front end? If i directly the variable d1(mentioned above) as java.sql.Date then there is arises compatibility error....

Help me pls..........
Sep 26 '07 #1
9 6539
madhoriya22
252 100+
My proj involves JSP @ front end n MySql @ back end and connectivity is established thru JDBC. The thing is when i store values from the front end into the db i need to change the data types n vice versa.Consider ths.

I m retrieving date from the db thru the result set i m traversing thru each n every record(next() function is used).

String d1 = rs.getString(2);System.out.println("Date="+date);

How do i convert the date field into a java.sq.Date value such dat it can be retrieved back @ front end? If i directly the variable d1(mentioned above) as java.sql.Date then there is arises compatibility error....

Help me pls..........
Hi,
Can u make urself more clear? when do you want to convert the date :
1. while sending date from jsp to mysql or
2. while getting date from db and sending it to jsp.
Sep 26 '07 #2
jith87
58
Hi,
Can u make urself more clear? when do you want to convert the date :
1. while sending date from jsp to mysql or
2. while getting date from db and sending it to jsp.

while getting date from db and sending it to jsp
Sep 26 '07 #3
madhoriya22
252 100+
while getting date from db and sending it to jsp
Hi,
then db itself retunrs date in sql format, isn't it ?
Sep 26 '07 #4
dmjpro
2,476 2GB
My proj involves JSP @ front end n MySql @ back end and connectivity is established thru JDBC. The thing is when i store values from the front end into the db i need to change the data types n vice versa.Consider ths.

I m retrieving date from the db thru the result set i m traversing thru each n every record(next() function is used).

String d1 = rs.getString(2);System.out.println("Date="+date);

How do i convert the date field into a java.sq.Date value such dat it can be retrieved back @ front end? If i directly the variable d1(mentioned above) as java.sql.Date then there is arises compatibility error....

Help me pls..........
Have a look at this Code.

Expand|Select|Wrap|Line Numbers
  1. Calendar c = new GregorianCalendar();
  2. c.setTime(rs.getDate(2));
  3. int day = c.get(Calendar.DATE);
  4. int month = c.get(Calendar.MONTH);
  5. int year = c.get(Calendar.YEAR);
  6. String date_str = ""+day+"/"+month+"/"+year;
  7.  
Are you looking for this?
Then go and enjoy with this code.
Good Luck!

Kind regards,
Dmjpro.
Sep 26 '07 #5
jith87
58
Hi,
then db itself retunrs date in sql format, isn't it ?

Yes bt i wanna convert the sql format date to java compatible date format. Wht to do for that?
Sep 26 '07 #6
dmjpro
2,476 2GB
Yes bt i wanna convert the sql format date to java compatible date format. Wht to do for that?
Have a look at my Code.
Then you will understand by yourself.

Kind regards,
Dmjpro.
Sep 26 '07 #7
jith87
58
Have a look at my Code.
Then you will understand by yourself.

Kind regards,
Dmjpro.

date_rs_test.java:36: cannot find symbol
symbol : variable Calendar

ths s the error dat i got....
Sep 26 '07 #8
r035198x
13,262 8TB
date_rs_test.java:36: cannot find symbol
symbol : variable Calendar

ths s the error dat i got....
Open the API docs for ResultSet and you will see that there is a getDate method.
Sep 26 '07 #9
dmjpro
2,476 2GB
date_rs_test.java:36: cannot find symbol
symbol : variable Calendar

ths s the error dat i got....
Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2.  
Kind regards,
Dmjpro.
Sep 26 '07 #10

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

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
0
by: Dan Anderson | last post by:
I ran a search through the mySQL manual and google and could not find a satisfactory answer. Does mySQL support the declaration of a boolean data type? Currently I am using VARCHAR(6)s with...
1
by: Hui | last post by:
Hi gurus, I'm having data conversion (marshalling) problems with VB.NET DLL calling a old C DLL. The problem is that when the return type is a Long, I'm getting some garbage large number. eg....
1
by: Amir | last post by:
Hi all, I have a table called PTRANS with few columns (see create script below). I have created a view on top that this table VwTransaction (See below) I can now run this query without a...
3
by: rdraider | last post by:
I'm doing a data conversion project, moving data from one SQL app to another. I'm using INSERT INTO with Select and have the syntax correct. But when executing the script I get: Server: Msg...
1
by: Ian Robinson | last post by:
Hi, I'm converting a desktop application Delphi/Paradox to a web server application PHP/MySQL What data type should I use in MySQL for the following paradox datatypes ? Boolean ? Currency ?
1
by: runsun | last post by:
I am new in PHP/Mysql. I want to input sth from website to mysql, then output the formatted data to .txt, and finally use Excel to open the .txt file. I believe there are better and simpler ways than...
6
by: John Moore | last post by:
My mysql data type is double(16,2) with '0.00' specified as default. These represent dollars and cent amounts. My question is: How do I perform simple mathematical operations on these money...
0
by: markwalsen | last post by:
I've been quite pleased with linking via MySQL Connector / ODBC 3.51 from Access to a remote MySQL database. However, I haven't figured out how to establish the link between a Data Type =...
6
by: dkyadav80 | last post by:
Hi guys, I have a form in html , all description below: first: name of persion (input type box) second: job profile (input type box) third: experience from: list box (Month : Jan, Feb,.....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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,...

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.