• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

How to retrieve a String stored in the DB?  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 67197
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Swapna Mandava
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post a code snippet

Thanks
Swapna
 
Qussay Najjar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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..
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Java Cowboy
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Search with Google for "JDBC tutorial".

http://java.sun.com/docs/books/tutorial/jdbc/
 
A timing clock, fuse wire, high explosives and a tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!