0 évaluation0% ont trouvé ce document utile (0 vote)
18 vues2 pages
Oracle odbc driver is used to connect to a database. You need to create a java project in netbeans IDE. The project should contain the package "java.sql"
Oracle odbc driver is used to connect to a database. You need to create a java project in netbeans IDE. The project should contain the package "java.sql"
Droits d'auteur :
Attribution Non-Commercial (BY-NC)
Formats disponibles
Téléchargez comme PDF, TXT ou lisez en ligne sur Scribd
Oracle odbc driver is used to connect to a database. You need to create a java project in netbeans IDE. The project should contain the package "java.sql"
Droits d'auteur :
Attribution Non-Commercial (BY-NC)
Formats disponibles
Téléchargez comme PDF, TXT ou lisez en ligne sur Scribd
2) In the Control Panel (Classic View), go to Administrative Tools 3) In Administrative Tools, select the icon “Data Sources (ODBC)”. On clicking this, a window is opened “ODBC Data Sources Administrator” 4) In this Administrator, select dBASE Files in User DSN and click on Add 5) On clicking Add Button, you will be asked to Create New Data Source… Select “Oracle In XE” from the given list 6) Now another window “Oracle ODBC Driver Configuration” will be opened. a. Add the Data Source Name, Eg: srikanth b. Click on OK 7) Check in the “ODBC Data Sources Administrator” whether your Data Source Name with the Database Driver i.e. “Oracle in XE” is displayed. If found you can use for the connectivity. Now while implementing in Java Application 1) Start NetBeans IDE 2) Select File -> New Project 3) Select Java in Categories 4) Select Java Application in projects 5) Click on Next 6) Enter project name, Eg: DBMSLAB13 7) Select project location, which is the folder where project is to be created. Don’t check the Create Main Class checkbox 8) Click on Finish 9) Now at your left side… You can see your project name… Open it and select “Source Packages” -> <default package> 10) Right click on “<default package>” -> New -> “Java Main Class” 11) Now the program for connectivity should contain the package “java.sql” 12) The program is import java.sql.*; public class DBConnectivity { public static void main(String args[]) { try { Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); Connection con = DriverManager.getConnection(“jdbc:odbc:dsn”,”username”,”password”); //dsn indicates the name given in Data Sources //username and password indicates the database username and password System.out.println(“Connected to Oracle”); con.close(); } catch(Exception ex) { System.out.println(ex); } } }
Now for implementing in JSP code
1) Start NetBeans IDE 2) Select File -> New Project 3) Select Java Web in Categories 4) Select Web Application in projects 5) Click on Next 6) Enter project name and location 7) Click on Next, Don’t change the Server settings 8) Click on Next and Finish 9) Now at your left side… You can see your project name… Open it and select “Web Pages” folder 10) Right click on New -> “JSP” 11) Give the file name (without giving .jsp extension) and click on finish 12) Now the program for connectivity should contain the package “java.sql” <%@ page import=”java.sql.*” %>