Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
OracleJdbcConnection.java - Oracle JDBC Connection
How to create a JDBC connection to Oracle database using the ojdbc Oracle Driver? I want to see a Java program example.
✍: FYIcenter.com
If you have Oracle Database 11g XE running on your local computer,
you can use the following example to learn how to create a JDBC connection:
// Copyright (c) FYIcenter.com
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
// Example of ojdbc JDBC connection to Oracle server
public class OracleJdbcConnection {
public static void main(String [] args) throws Exception {
// Use the basic ojdbc JDBC connection URL
String url = "jdbc:oracle:thin:SYS AS SYSDBA/fyicenter@//localhost/XE";
Connection con = DriverManager.getConnection(url);
System.out.println("JDBC connection and database server information:");
DatabaseMetaData meta = con.getMetaData();
System.out.println("Database Product Name: "
+ meta.getDatabaseProductName());
System.out.println("Database Product Version: "
+ meta.getDatabaseProductVersion());
System.out.println("Driver Name: "
+ meta.getDriverName());
System.out.println("Driver Version: "
+ meta.getDriverVersion());
System.out.println("JDBC Major Version: "
+ meta.getJDBCMajorVersion());
System.out.println("JDBC Minor Version: "
+ meta.getJDBCMinorVersion());
// Close the connection
con.close();
}
}
You can compile and run the above example in a command window as shown below:
C:\fyicenter>\local\jdk-1.8.0\bin\javac OracleJdbcConnection.java C:\fyicenter>\local\jdk-1.8.0\bin\java -cp .;\fyicenter\Oracle-11.2.0.4\ojdbc6.jar OracleJdbcConnection JDBC connection and database server information: Database Product Name: Oracle Database Product Version: Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production Driver Name: Oracle JDBC driver Driver Version: 11.2.0.4.0 JDBC Major Version: 11 JDBC Minor Version: 2
The output shows that:
⇒ OracleCreateTable.java - Oracle JDBC Create Table
⇐ Start Oracle Database 11g XE on Windows
2018-03-28, ∼2747🔥, 0💬
Popular Posts:
jlGui is a music player for the Java platform. It is based on Java Sound 1.0 (i.e. JDK 1.3+). It sup...
maven-embedder-3.8.6.jar is the JAR file for Apache Maven 3.8.6 Embedder module. Apache Maven is a s...
What Is poi-ooxml-3.5.jar? poi-ooxml-3.5.jar is one of the JAR files for Apache POI 3.5, which provi...
What Is poi-5.2.3.jar? poi-5.2.3.jar is one of the JAR files for Apache POI 5.2.3, which provides an...
What Is wstx-asl-3.2.8.jar? wstx-asl-3.2.8.jar is JAR file for the ASL component of Woodstox 3.2.8. ...