We can connect Oracle database in Java. We can write
following code:
import java.sql.*;
1.
Class DbConnection{
2.
public static void main(String
args[]){
3.
Class.forName(“oracle.jdbc.driver.OracleDriver”);
4.
Connection
conn=DriverManager.getConnection(“jdbc:oracle:thin:@localhost:1521:xe”,”system”,”java”);
5.
System.out.println(“Database
connects successfully……………”);
6.
conn.close();
7.
}
8.
}
Note: system is user name of
Dbbase and java is password.
We can execute this code on editor
and IDE.
On Notepad:
Save: DbConnection.java
Open CMD prompt:
0 comments:
Post a Comment