title: How to create a column in oracle with object data type
body: <p>I'm a web developer. I'm from Javascript and Typescript background. A few days ago I decided to learn JDBC with Oracle. I've created a very basic JDBC project with JavaFX and Oracle. (Actually I'm trying to mimic Microsoft Azure). I've a Date field also which will get its value from JavaFx  built-in Datepicker component. Here is some useful information:</p>
  <p><strong>Columns in table: mybranches</strong></p>
  <ol>
  <li>branch_name varchar(50)</li>
  <li>branch_created_on date</li>
  <li>branch_pulled_from varchar(50)</li>
  </ol>
  <p>The problem is the 2nd column i.e. the <code>branch_created_on</code> field.</p>
  <p>Here's my java code: <strong>DataService.java</strong></p>
  <pre><code>import java.time.LocalDate;
  ...
  
  public class DataService {
      Connection con;
      PreparedStatement pstmt;
      
      static String branch_name=&quot;&quot;;
      static LocalDate branch_created_on;
      static String branch_pulled_from=&quot;&quot;;
      
      DataService() {
          try {
              Class.forName(&quot;oracle.jdbc.driver.OracleDriver&quot;);
              con=DriverManager.getConnection(&quot;jdbc:oracle:thin:@localhost:1521:xe&quot;,&quot;tiger&quot;,&quot;scott&quot;);
          }
          catch(Exception e){ 
              System.out.println(e);
          }
      }
      
      public void getValue() {
          branch_name=AddNewBranchRecord.branchNameTextField.getText();
          branch_created_on=AddNewBranchRecord.datePicker1.getValue();
          branch_pulled_from=(String) AddNewBranchRecord.combo_box_1.getValue();
      }
      
      public void putValue() {
          System.out.println(&quot;Branch name: &quot;+branch_name);
          System.out.println(&quot;Branch created on: &quot;+branch_created_on);
          System.out.println(&quot;Branch pulled from: &quot;+branch_pulled_from);
      }
      
      public void insertRecord() {
          getValue();
          try {
              pstmt=con.prepareStatement(&quot;INSERT INTO mybranches (branch_name,branch_created_on,branch_pulled_from) VALUES (?,?,?)&quot;);  
              pstmt.setString(1,branch_name);
              pstmt.setObject(2,branch_created_on);
              pstmt.setString(3,branch_pulled_from);
              pstmt.execute();
          } catch (SQLException ex) {
              Logger.getLogger(DataService.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
  }
  </code></pre>
  <p>The output of <code>putValue</code> is also correct:</p>
  <blockquote>
  <p>Branch name: 1000-test</p>
  <p>Branch created on: 2020-02-11</p>
  <p>Branch pulled from: master</p>
  </blockquote>
  <p>But the moment I call <code>insertRecord</code> method, I get this exception:</p>
  <blockquote>
  <p>SEVERE: null</p>
  <p>java.sql.SQLException: Invalid column type</p>
  <p>at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)</p>
  <p>...</p>
  </blockquote>
  <p>This exception is not there If I remove that date column from the database table as well as java code. I'm extremely sorry If I'm asking a stupid question. I'm from Angular and React background. Please correct me.</p>