JDBC

JDBC Projects

JDBC Project 1

adplus-dvertising
JDBC Using PreparedStatement example–Create a table
Previous Home Next
/* This example shows you how to create a table in 
the database using JDBC PreparedStatement.*/

package r4r;
import java.sql.*;
public class CreateTable
{
public static void main(String[] args) 
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:
thin:@localhost:1521:xe","system","oracle");
PreparedStatement stmt=con.prepareStatement("create table gaurav
(name varchar2(8),id number(8))");
stmt.executeUpdate();
System.out.println("Successfully created");
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}

output:

Successfully created
Previous Home Next