Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on JSP database connectivity within the JSP forums, part of the Web Development category; how conncet the oracle database by using JSP. Reteriving the data from database by using JSP....
|
|||||||
|
|||
|
Re: JSP database connectivity
Quote:
What type of connection are you planning to use? e.g. Pool Connecion or Driver Connection. Pool Connection is via the Web Server while Driver Connection is using calling the database via the respective database JDBC Drivers. Code: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection( database ,"",""); Thanks, Riju. Last edited by rijus; 09-14-2009 at 11:54 AM. |
|
|||
|
Re: JSP database connectivity
import java.io.*;
import java.sql.*; public class OraThin { public static void main(String[] args) { try { Connection con=null; Class.forName("oracle.jdbc.driver.OracleDriver"); con=DriverManager.getConnection( "jdbc racle:thin:@machine_name:1521:database_name","scott", "tiger"); Statement s=con.createStatement(); s.execute(" INSERT INTO BOOKS VALUES ( 'A Tale of Two Cities', 'William Shakespeare', 4567891231, '5-JAN-1962' ) "); s.close(); con.close(); } catch(Exception e){e.printStackTrace();} } } |
|
|||
|
Re: JSP database connectivity
mport java.io.*;
import java.sql.*; public class ConnectionManager { public Connection getConnection { try { Connection con=null; Class.forName("oracle.jdbc.driver.OracleDriver"); con=DriverManager.getConnection( "jdbcracle:thin:@machine_name ort:database_name","username","password");return con; } catch(Exception e){e.printStackTrace();} } } This class return the connection with oracle db. so make a onject of this class and call a getConnection method and take connection like... ConnectionManager cm = new ConnectionManager(); Connection con=cm.getConnection(); Thx Amit Jain |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Does PHP support all database connectivity? | mca_207 | PHP | 1 | 07-25-2009 11:42 AM |
| AJAX Made Easy - IBM Database Connectivity for JavaScript | Lokesh M | AJAX & XML | 0 | 06-17-2008 03:20 PM |
| database connectivity | anver | SQL Server | 2 | 06-13-2008 06:13 AM |
| About cpp connectivity | govindaraj123 | Mathematical Puzzles | 5 | 08-06-2007 03:11 AM |
| I am getting database connectivity error | sumana_i | Test Director | 0 | 04-06-2007 04:24 AM |