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
Understand IntialContext
Costa lamona
Ranch Hand
Posts: 102
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi
I don't understand at all how this code works?
it comes from this tutorial
http://java.sun.com/docs/books/tutorial/jdbc/basics/connecting.html
InitialContext ic = new InitialContext() DataSource ds = ic.lookup("java:comp/env/jdbc/mydb"); Connection con = ds.getConnection(); DataSource ds = (DataSource) org.apache.derby.jdbc.ClientDataSource() ds.setPort(1527); ds.setHost("localhost"); ds.setUser("APP") ds.setPassword("APP"); Connection con = ds.getConnection();
Thanks
SCJP 5
Bauke Scholtz
Ranch Hand
Posts: 2458
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The first part obtains a DataSource instance from the JNDI and gets a connection of it.
The second part doesn't compile, but its intent is to create a DataSource instance yourself, configure it yourself and finally get a connection of it.
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Database and J2ee server help needed!
How to configure hsqldb in struts 1.3.8?
Problem using DataSource with core java app
Creating Datasource
Setting up Datasource object
More...