Java Programming/Database Programming

Java uses, an API that defines how a client may access a database. Its drivers may be installed first.

Connecting to databases
The following is used to open an connection to an Access database. Note that the username (and password, if applicable) are given in the DSN rather than the  call. This is a MS Windows-only example, due to the requirement for the Microsoft Access Driver.

Connecting to Oracle Database
This script returns the database size:

package oracle.jdbc does not exist
If you have Oracle Database on your PC, just add to the classpath its following files :
 * C:\oracle12\app\oracle\product\12.1.0\dbhome_1\jdbc\lib\ojdbc7.jar
 * C:\oracle12\app\oracle\product\12.1.0\dbhome_1\sqlj\lib\runtime12.jar

Otherwise, ojdbc7.jar can be downloaded from http://www.oracle.com/technetwork/database/features/jdbc/jdbc-drivers-12c-download-1958347.html, and add it to the compilation. Eg: javac MyClass.java -classpath ojdbc7.jar

ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
Just add " as sysdba" after your Oracle account name, eg: Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:MyDatabase", "MyAccount as sysdba",