connecting to a database

W

w00

Hello, i've installed NetBeans with the Derby Database. I've created a
table with some content in it. Now i want to create a simple JSP file
where i can connect to the database and select an item from a table.
I just dont know how to do that, i couldn't find anything on the net
either about this. So i hope someone here can help me out.
 
A

Andrew Thompson

w00 said:
Hello, i've installed NetBeans with the Derby Database. I've created a
table with some content in it. Now i want to create a simple JSP file
where i can connect to the database and select an item from a table.
I just dont know how to do that, i couldn't find anything on the net
either about this.

If you are looking for examples of connecting to a
DB from a JSP - you might be disappointed.
I suspect most of the answers will revolve around
a) accessing a DB (whether it is from an applet,
application, web-app., or the command line)
...or..
b) Writing JSP's.

But then, try doing a DB access from an application,
(with or without GUI) and I think you'll find most of the
code can be 'copy/pasted' into a JSP.

Andrew T.
 
W

w00

Andrew said:
If you are looking for examples of connecting to a
DB from a JSP - you might be disappointed.
I suspect most of the answers will revolve around
a) accessing a DB (whether it is from an applet,
application, web-app., or the command line)
..or..
b) Writing JSP's.

But then, try doing a DB access from an application,
(with or without GUI) and I think you'll find most of the
code can be 'copy/pasted' into a JSP.

Andrew T.


So you're saying that there isn't much about connecting to a Database
with JSP files...??
I know how to connect to a databse with php, its just calling the
'mysql_select_db()' function. But i can't just guess what the function
would be in Java with a Derby Database...

There must be some resources/tutorials about this somewhere right...
 
M

Mich

w00 said:
Hello, i've installed NetBeans with the Derby Database. I've created a
table with some content in it. Now i want to create a simple JSP file
where i can connect to the database and select an item from a table.
I just dont know how to do that, i couldn't find anything on the net
either about this. So i hope someone here can help me out.


create a class that connects to the database and then invoke the class from
the jsp
 
D

Denz

w00 said:
Hello, i've installed NetBeans with the Derby Database. I've created a
table with some content in it. Now i want to create a simple JSP file
where i can connect to the database and select an item from a table.
I just dont know how to do that, i couldn't find anything on the net
either about this. So i hope someone here can help me out.

I have no idea about Derby specifically, but assuming it connects just the
same as any other JDBC connection, you may be able to get some pointers
from this page i put together for connecting to a MySQL database from jsp
pages (using Tomcat as the jsp server):
http://gus.gscit.monash.edu.au/~dmgel2/tomcat.html
 
J

John O'Conner

w00 said:
Hello, i've installed NetBeans with the Derby Database. I've created a
table with some content in it. Now i want to create a simple JSP file
where i can connect to the database and select an item from a table.
I just dont know how to do that, i couldn't find anything on the net
either about this. So i hope someone here can help me out.

Connecting to Java DB or Derby from a JSP page requires the same code as
from a desktop application....although that code may be handled by
tags or other libraries.

The following article can help you connect to a Java DB (Apache Derby)
db from a desktop application:
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javadb/

The basic ideas you want to pay attention to are these:
* including the derby.jar or derbyclient.jar files in the app classpath
* loading the driver
* connecting to the db
* executing sql statements using the jdbc classes and methods.

The article should help considerably.

Regards,
John O'Conner
 
A

Andrew Thompson

Denz said:
I have no idea about Derby specifically, but assuming it connects just the
same as any other JDBC connection, you may be able to get some pointers
from this page i put together for connecting to a MySQL database from jsp
pages (using Tomcat as the jsp server):
http://gus.gscit.monash.edu.au/~dmgel2/tomcat.html

There is nothing quite like making a public statement
in an archiveable medium to find out ..I'm wrong. ;-)

Nice page. I especially like the styling (info. seems
good and clear, too).

BTW - noticed one tiny typo. just before the start of
step 2 - 'atleast' with no space.

Andrew T.
 
L

Lew

So you're saying that there isn't much about connecting to a Database
with JSP files...??
I know how to connect to a databse with php, its just calling the
'mysql_select_db()' function. But i can't just guess what the function
would be in Java with a Derby Database...

There must be some resources/tutorials about this somewhere right...

JSTL tag library has SQL tags.

See Chapter 14 of the Sun JEE tutorial:
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html

- Lew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top