Forums Register Login

basic simple jsp/bean/servlet cms mysql datasource

+Pie Number of slices to send: Send
Hello!

I have built numerous webapps in php/mysql over the years that allow insert/modify/delete of db content...however, I am having some difficulty wrapping my brain around the java approach... I'm still not clear on what a "flow-chart" of the process would look like..(i.e. jsp form > servlet > bean > servlet > db > bean > servlet > jsp display ???)

Can anyone point me to a very simple example (employee data, cd collection, event calendar, etc...) that could help make this clear for me?

I had the j2ee structure thrust upon me due to my company purchasing websphere and all anyone could tell me was that I need to use the following code

****
InitialContext ctx = new InitialContext();
ds = (DataSource) ctx.lookup("java:comp/env/xxxxxx");
****

I guess I'll still need to figure out the necessary "package imports" and all the "exception handling", but I'm hoping to find something that will allow me to "drop in" this code and make minor edits to the db queries (which I DO understand...)

All replies will be greatly appreciated -- Thanks in advance!!!
+Pie Number of slices to send: Send
"Web Producer",

Glad that you're here with us on the good ol' JavaRanch and I reckon that you'll find this a helpful and useful site, but we do got us a few rules that y'all got to play by. One of these is that proper ID is required before you can belly on up to the bar. Please take a gander at the JavaRanch Naming Policy and adjust your display name to match it.

The particulars is that your display name must be a first and a last name separated by a space character, and must not be obviously pulling our legs!

Thank ya kindly!
bear
Forum Bartender
+Pie Number of slices to send: Send
For my apps, the usual flow of this kind of deal is usually along the lines of

1) JSP form submits to servlet
2) Servlet utilizes business layer to perform appropriate action
3) Servlet gathers info for display, data (usually beans) is placed in scoped variables on the request
4) Servlet forwards to JSP page

Sometimes there's a 3b where the processing servlet fowards to a "display prep" servlet if appropriate.
+Pie Number of slices to send: Send
Sorry about the "alias" there...
I try to set up accounts so that when the time comes for me to leave the job, my successor can continue using the accounts...
Anyway...
I should be showing up as "Sean McKernan" now....Web Producer at Bryant University in Smithfield, RI...
Thanks for the chance to make it right....
+Pie Number of slices to send: Send
No prob! Thanks for responding so quickly.
+Pie Number of slices to send: Send
You're quite welcome - thanks for providing this great space!!!

Anyway...

Back to the post...

Here is part of the question:

As for the code I mentioned earlier:

****
InitialContext ctx = new InitialContext();
ds = (DataSource) ctx.lookup("java:comp/env/xxxxxx");
Connection conn = ds.getConnection();
****

Does this constitute a straightforward one-to-one replacement for the following code?

****
Class.forName("com.imaginary.sql.msql.MsqlDriver");
String url = "jdbc:msql://www.myserver.com:1114/contact_mgr";
Connection conn = DriverManager.getConnection(url,"user1","password");
****
+Pie Number of slices to send: Send
Sean,
Yes, it is a one to one correspondence (assuming you set up a datasource on the server.)
+Pie Number of slices to send: Send
Great!! Thanks!
Don't mess with me you fool! I'm cooking with gas! Here, read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2067 times.
Similar Threads
JNDI Lookup help in websphere 4.0
JBoss 3.2.x, MySQL and Connection Pooling Question
Not able to perform JNDI lookup in my servlet
Not able to perform JNDI lookup
Setting up Datasource object
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:16:53.