Basics of DataSource : Datasource is a name given to the connection set up to a database from a server . DataSource is an alternative to DriverManager for getting the connection . We should prefer database connections getting from a DataSource instead of a DriverManager. Using a Datasource you need to know only the JNDI name. The JNDI style is typical when using an application server or a web container Java Example for configuring and accessing a DataSource : -------------------------------------------------------- 1) Configure the JNDI DataSource in Tomcat by adding a declaration for your resource to your Context in server.xml <Resource name="jdbc/myoracle" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@127.0.0.1:1521:mysid" ...
Posts
Showing posts from July, 2014