René Nyffenegger's collection of things on the web | |
René Nyffenegger on Oracle - Most wanted - Feedback
- Follow @renenyffenegger
|
Java and Oracle: Creating a table | ||
CreateTable.java
import java.sql.*; import oracle.jdbc.pool.OracleDataSource; class CreateTable { public static void main (String args[]) throws SQLException { OracleDataSource data_source = new OracleDataSource(); data_source.setURL("jdbc:oracle:thin:rene/my_secret@localhost:1521:XE"); Connection connection = data_source.getConnection(); Statement statement = connection.createStatement(); statement.executeUpdate( "create table jdbc_test (" + " col_1 number, " + " col_2 varchar2(20), " + " col_3 date) " ); } }
The table is created with executeUpdate because the statement modifies (updates) the database.
See also:
Inserting into the table and
Selecting from the table.
|