I want to enter a command with JDBC to create a table, but after the first compilation, when the table has already been generated, each next one throws an exception. I don’t understand how this is possible, because I put [IF NOT EXISTS] there, so there should be no SQL error.
public class Test { public static void main(String[] args) { try { Connection conn = BazaDanych.Polacz(); Statement stat = conn.createStatement(); String command = "CREATE TABLE [IF NOT EXISTS] testowatabela2 (id INTEGER, wartosc DOUBLE PRECISION);"; stat.execute(command); } catch(SQLException e) { System.out.println("SQL Exception in Test"); } } }
source share