database & JSP

Hi everyone,

I am working with a database from SQL Server and a .jsp,

but, I can't pass the a value of the database to my program,

example:

<input type="hidden" name="price" value="19.95">

Float price =new Float(request.getParameter("price"));

In this case, I have this input type hidden with a value of 19.95,

then I do a request and get that value, that is worling ok,

But, if I want to get it from the database,

how do i do it?

here's how I declared the database code:

Connection connection = DriverManager.getConnection("jdbc:odbc:testDatabase","","");

Statement statement = connection.createStatement() ;

ResultSet resultset = statement.executeQuery("select price from pre3") ;

<TABLE BORDER="1">

<TR>

<TH>Name</TH>

</TR>

<%while(resultset.next()){ %>

<TR>

<TD>

<%= resultset.getString(1)%>

</TD>

</TR>

<%} %>

</TABLE>

the connection to the database is working fine, and gets printed as you can see, but, I don't how can I pass it to the Float price =new Float

what can I do to solve this?

thanks...

[1652 byte] By [deroka] at [2007-11-27 7:27:55]
# 1
So are you going to put the username and password to your database in your jsp ? That's a very bad idea. You should never be connecting to a database from a jsp.
Aknibbsa at 2007-7-12 19:08:10 > top of Java-index,Java Essentials,Java Programming...
# 2
> So are you going to put the username and password to> your database in your jsp ? That's a very bad idea.> You should never be connecting to a database from a> jsp.I would go further -- no code scriplets in a JSP.
Hippolytea at 2007-7-12 19:08:10 > top of Java-index,Java Essentials,Java Programming...
# 3

> So are you going to put the username and password to

> your database in your jsp ? That's a very bad idea.

> You should never be connecting to a database from a

> jsp.

No, i am not putting username or password in the .jsp,

This is just something that i'm testing,

the value I am requesting from the database is a float(2.95),

and i just want to use that in my .jsp,

I have to do some parse or convert it to something?

deroka at 2007-7-12 19:08:10 > top of Java-index,Java Essentials,Java Programming...
# 4

> > So are you going to put the username and password

> to

> > your database in your jsp ? That's a very bad

> idea.

> > You should never be connecting to a database from

> a

> > jsp.

>

> I would go further -- no code scriplets in a JSP.

Fair enough but I figured crawl before walking.

Aknibbsa at 2007-7-12 19:08:10 > top of Java-index,Java Essentials,Java Programming...
# 5
come on guys..give me an idea, please.
deroka at 2007-7-12 19:08:10 > top of Java-index,Java Essentials,Java Programming...
# 6
> come on guys..> give me an idea, please.Take the J2EE tutorial, and be sure to pay attention when you get to chapter nine: JavaServer Faces. http://java.sun.com/javaee/5/docs/tutorial/doc/
Hippolytea at 2007-7-12 19:08:10 > top of Java-index,Java Essentials,Java Programming...
# 7
> > I would go further -- no code scriplets in a JSP.> Fair enough but I figured crawl before walking.so why start crawling into an abyss? You'll never learn to walk as you'll be stuck at rock bottom trying to crawl your way out on a slippery slope...
jwentinga at 2007-7-12 19:08:10 > top of Java-index,Java Essentials,Java Programming...
# 8
> come on guys..> give me an idea, please.no, we're not going to help you do things that way. Use proper application architecture and use a servlet or EJB for database access.
jwentinga at 2007-7-12 19:08:10 > top of Java-index,Java Essentials,Java Programming...