Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes servlet  queries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "servlet  queries" Watch "servlet  queries" New topic
Author

servlet queries

jagan billa
Greenhorn

Joined: Dec 05, 2011
Posts: 11
How to use this query in servlet
*****combine two database******

database1:registration
database2:shopping_cart
online is a common table in both database

SELECT registration.online.price, shopping_cart.online.name FROM registration.online, shopping_cart.online WHERE registration.online.id = 1 AND shopping_cart.online.id = registration.online.id;

how to define two database name in this

c=DriverManager.getConnection("jdbc:mysql://localhost:3306/database name","root","root");


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

You just need one of the two databases to connect to. The database prefix inside the query will take care of the rest.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Janarthanan Rajendran
Greenhorn

Joined: Nov 07, 2011
Posts: 7

Do not use Business logic inside Servlets, it should always go through Service classes.

Regards,
Jana
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: servlet queries
 
Similar Threads
Passing value from one servlet to another
why aliase in servlet or jsp
Problem getting servlets working
Definitions and usage of getContext()
Please help for Context root