jdbc连接oracle创建表

/**
     * ORACLE连接地址
     */
    private static final String DATASOURCE_RRL = "jdbc:oracle:thin:@127.0.0.1:1521:runhe";
    /**
     * ORACLE用户名
     */
    private static final String DATASOURCE_USERNAME = "admin";
    /**
     * ORACLE密码
     */
    private static final String DATASOURCE_PASSWORD = "123456";
    /**
     * ORACLE连接池
     */
    private static final String DATASOURCE_DRIVER = "oracle.jdbc.driver.OracleDriver";
/**
     * jdbc连接oracle穿件表
     * 
     * @param createTableStr
     */
    public static void createTable(String ddlStr) {
        try {
            Class.forName(DATASOURCE_DRIVER);
            Connection conn = DriverManager.getConnection(DATASOURCE_RRL, DATASOURCE_USERNAME, DATASOURCE_PASSWORD);
            Statement stmt = conn.createStatement();
            stmt.executeUpdate(ddlStr);
            System.out.println("Create table Success!");
            stmt.close();
            conn.close();
        } catch (java.lang.ClassNotFoundException e) {
            System.err.print(e.getMessage());
        } catch (SQLException ex) {
            System.out.println("\n***SQLException caught ***\n");
        }
    }

需要jar包

下载地址:https://mvnrepository.com/search?q=ojdbc6

你可能感兴趣的:(Java)