aspose file tools*
The moose likes JDBC and the fly likes Simple question about using JDBC to access DB2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Simple question about using JDBC to access DB2" Watch "Simple question about using JDBC to access DB2" New topic
Author

Simple question about using JDBC to access DB2

George Lin
Greenhorn

Joined: Feb 22, 2006
Posts: 28
Hello everyone,


I want to use JDBC to access DB2 database. I also want to display the content of a specific table (table name is configurable) into web page (just like what is displayed when we use command line "select * from <table name>" on the console). I am wondering whether there are any existing sample which is easy and quick to learn with source codes.


thanks in advance,
George
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

"GeorgeNew GeorgeNew,"

Welcome to JavaRanch!

Please revise your display name to meet the JavaRanch Naming Policy. To maintain the friendly atmosphere here at the ranch, we like folks to use real (or at least real-looking) names, with a first and a last name. You can edit your name here.

We have a forum specifically for JDBC. You will probably get better responses there, so I'll move this post for you...

-Marc
[ February 22, 2006: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
George Lin
Greenhorn

Joined: Feb 22, 2006
Posts: 28
marc,


Originally posted by marc weber:
"GeorgeNew GeorgeNew,"

Welcome to JavaRanch!

Please revise your display name to meet the JavaRanch Naming Policy. To maintain the friendly atmosphere here at the ranch, we like folks to use real (or at least real-looking) names, with a first and a last name. You can edit your name here.

We have a forum specifically for JDBC. You will probably get better responses there, so I'll move this post for you...

-Marc

[ February 22, 2006: Message edited by: marc weber ]


I have just changed my name. Thank you very much for your thread moving. Cool.


regards,
George
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
Originally posted by GeorgeNew GeorgeNew:
I want to use JDBC to access DB2 database. I also want to display the content of a specific table (table name is configurable) into web page (just like what is displayed when we use command line "select * from <table name>" on the console).


Normally, Java folk who want to dynamicly generate web pages do so using JSP (Java Server Pages), which is a J2EE technology. A lot of people are using Tomcat and/or JBOSS as their J2EE engine, but there are a lot of other choices.

As far as getting started with JDBC, and with JDBC and JSP, here are some good links:
http://java.sun.com/docs/books/tutorial/jdbc/index.html
http://www.javaolympus.com/J2SE/Database/JDBC/JDBCJSP.jsp
George Lin
Greenhorn

Joined: Feb 22, 2006
Posts: 28
stu,


Originally posted by stu derby:


Normally, Java folk who want to dynamicly generate web pages do so using JSP (Java Server Pages), which is a J2EE technology. A lot of people are using Tomcat and/or JBOSS as their J2EE engine, but there are a lot of other choices.

As far as getting started with JDBC, and with JDBC and JSP, here are some good links:
http://java.sun.com/docs/books/tutorial/jdbc/index.html
http://www.javaolympus.com/J2SE/Database/JDBC/JDBCJSP.jsp



Thank you very much! The links are very helpful. The questions I had is how to make UI on web pages to present data retrieved from database. I do not want to make this work too complex like J2EE since my requirements are very simple -- just display the content of a whole table by the table name.

Do you have any further comments?


regards,
George
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

"George George",

Your display name must be a first and last name -- not your first name twice. Please adjust your display name to be a first and last name prior to your next post.

Be advised that accounts with invalid display names are subject to removal.

bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
George Lin
Greenhorn

Joined: Feb 22, 2006
Posts: 28
Bear,


Originally posted by Bear Bibeault:
"George George",

Your display name must be a first and last name -- not your first name twice. Please adjust your display name to be a first and last name prior to your next post.

Be advised that accounts with invalid display names are subject to removal.

bear
JavaRanch Sheriff


I have changed my display name. Please review. Please also feel free to let me know if I need to do further updates. :-)


thanks a lot,
George
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
It may seem simple to you, but it's not. The part you're not thinking about is the network part; the code that opens a socket, listens for a web request, dispatches any requests for processing and simultaneously keeps listening for more requests, deals with sockets that are abruptly closed (because the browser was stopped, etc., etc.

While you may not need a full-blown J2EE server, you do need to either write all the above and more, or use a servlet container. Tomcat is the most popular, and free.
http://tomcat.apache.org/

Once you have a servlet container running, then you can start thinking about how to populate the content of your web pages.
Ben Zung
Ranch Hand

Joined: Mar 25, 2004
Posts: 109
Stu is right, George. There is no way to catch the bus without getting to the bus stop.
Suppose you have had tomcat installed and running first.
Write your jsp page or servlet class using jdbc to connect to your db
In your JSP page/Servlet class, parse the ResultSet(You may want to use ResultSet MetaData's getColumnName() method to get the table names)
Use a HTML Table to display your table content -- the column names being the table headers.
(And close your connection)
I have some examples of my own and if you're interested, let me know offline, I'd be happy to share with u.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple question about using JDBC to access DB2