1 Reply Latest reply: Dec 28, 2013 9:48 AM by Suntrupth RSS

    I am trying to send data from textfield to database but it is showing error "ORA-12899: value too large for column "HR"."DOCTORS"."NAME" (actual: 658, maximum: 20)"

    1b0a4c88-e966-424f-a986-7d6d8e2a456d

      Although i am entering only one character into the textfield then too it is reflecting the same error.







      private void initEvents()

      {

        okButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

        Connection conn = null;

          Statement stmt = null;

          try{

             //STEP 2: Register JDBC driver

             Class.forName("oracle.jdbc.driver.OracleDriver");

       

       

             //STEP 3: Open a connection

             System.out.println("Connecting to database...");

             conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","hr","hr");

       

       

             //STEP 4: Execute a query

             System.out.println("Creating statement...");

             stmt = conn.createStatement();

             System.out.println(txtField);

             String sql = "INSERT INTO DOCTORS VALUES ('"+txtField+"','"+textField_1+"','"+textField_1+"','"+textField_2+"','"+textField_3+"')";

       

            

             JOptionPane.showMessageDialog(null,"Inserted Successfully!");

        

             ResultSet rs = stmt.executeQuery(sql);

             rs.close();

             stmt.close();

             conn.close();

          }catch(SQLException se){

             //Handle errors for JDBC

             se.printStackTrace();

          }catch(Exception e1){

             //Handle errors for Class.forName

             e1.printStackTrace();

          }finally{

             //finally block used to close resources

             try{

                if(stmt!=null)

                   stmt.close();

             }catch(SQLException se2){

             }// nothing we can do

             try{

                if(conn!=null)

                   conn.close();

             }catch(SQLException se){

                se.printStackTrace();

             }//end finally try

          }//end try

        }

        });