*
The moose likes JDBC and the fly likes How to retrieve a String stored in the DB? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to retrieve a String stored in the DB?" Watch "How to retrieve a String stored in the DB?" New topic
Author

How to retrieve a String stored in the DB?

Swapna Mandava
Greenhorn

Joined: Feb 05, 2008
Posts: 6
Hi,

Can some one pls. tell me how to retrieve a string stored in the DB? Which classes are required to accomplish this? Pls. answer my query asap.

Thanks alot,
Swapna
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

Please use real words when posting to the forums. Abbreviations such as "pls" in place of "please" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
kkk guptha
Greenhorn

Joined: Nov 17, 2007
Posts: 3
Hi,
I think Data coming from DB default is String only.
If you want to convert into Integer type, int i = Integer.parseInt(string);


--- KKKGuptha
Qussay Najjar
Ranch Hand

Joined: Jan 18, 2008
Posts: 53
Originally posted by Swapna Mandava:
tell me how to retrieve a string stored in the DB? Which classes are required to accomplish this?
Swapna


do you know how to create Statement, and get your records into a ResultSet? because the value will come by default as String.
if you don't know just inform me and I'll post you a snippet code to understand it.


Qussay NAJJAR
Swapna Mandava
Greenhorn

Joined: Feb 05, 2008
Posts: 6
Please post a code snippet

Thanks
Swapna
Qussay Najjar
Ranch Hand

Joined: Jan 18, 2008
Posts: 53
Originally posted by Swapna Mandava:
Please post a code snippet

Thanks
Swapna


Ok, the process is going to be like the next:
1- Your Connection should be created and done.
2- we have then to create an object called Statement out of that Connection.


inform if need something else..have fun..
Shilpa Tendulkar
Ranch Hand

Joined: Jul 29, 2001
Posts: 75
Originally posted by kkk guptha:
Hi,
I think Data coming from DB default is String only.
If you want to convert into Integer type, int i = Integer.parseInt(string);


--- KKKGuptha

If you know the datatype of fields in table, then you can directly use ResultSet's methods to get that type of data instead of parsing.
Like rs.getInt("col_name") or rs.getDouble("col_name") etc.


SCJP5
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Search with Google for "JDBC tutorial".

http://java.sun.com/docs/books/tutorial/jdbc/


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to retrieve a String stored in the DB?
 
Similar Threads
encoding from BIG5 to UTF8
voice input
Save binary file in DB using entity EJB
VARBINARY in sp -how-to
Retrieve maximum value