Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JDBC and Relational Databases
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JDBC and Relational Databases
generic Jdbc code which can take different vendor database and driver selection from user
ravi taneja
Greenhorn
Posts: 1
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi guys,
want to build a
jdbc
code which can have database choice and driver selection entered by user. we should be able to
load the driver and pass the connection url for different databases at runtime........
Please help me out...
ravi
Wei Dai
Ranch Hand
Posts: 86
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public synchronized void service(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException { try { String url=request.getParameter("url"); String driver=request.getParameter("driver"); Class.forName(driver).newInstance(); String user=request.getParameter("user"); String password=request.getParameter("password"); Connection connection=DriverManager.getConnection(url,user,password); //... } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); //... } }
Wendy L Gibbons
Bartender
Posts: 1111
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Wei please use code tags, see how much prettier and easy to read they make your code.
Anyway expecting users to know the driver name is a bit off.
We used to have a properties file with the actual details, then the user could choose a helpfull name, and that linked to all of the dirty details.
I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
How to make a data source connection without writing a User name & Password and the -ds.xml file
Creating a very basic JDBC driver
Please help with DataSource problem
MySql
JDBC-DB2 connectivity issue
More...