Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-16-2007, 02:25 AM
Member
 
Join Date: Jul 2007
Posts: 2
Rep Power: 0
Lagarto is on a distinguished road
Default Passing the Values
Hello all

I'm trying to do an INSERT using Netbeans as my IDE, and SQL server 2005 Express as my DB engine.

When i compile my code its error free, but when i execute it wont do what its supposed to do.. Its not doing the insert.. i don't know exactly how to pass the values. Here's the code:

Thanks!

Code:
private void IngresarActionPerformed(java.awt.event.ActionEvent evt) {                                         
    Connection conexion;
    Statement sentencia;
    
    try{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    }
     catch (Exception e){
    System.out.println("No se pudo conectar con el JDBC-ODBC");      
     return;
    }  
    
    try{
        conexion = DriverManager.getConnection("jdbc:odbc:con_sql","",""  );
        sentencia = conexion.createStatement();
        PreparedStatement insertar = conexion.prepareStatement("EXECUTE dbo.insertar " );
        
       
        
         
     
         
         String Nom = ("Nombre");
         String Ape = ("Apellido");
         String Ced = ("Cedula");
         String FechaN = ("Fecha_Nacimiento");
         String Sueldo = ("Sueldo");
         String TPrimario = ("Telefono_Primario");
         String TSecundario = ("Telefono_Secundario");
         String Movil = ("Movil");
         String Direccion = ("Direccion");
         
         
         
         
         
         
         
        
    }   
catch( Exception e ) {
         System.out.println( e );
         return;
         }
    }
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-16-2007, 04:03 AM
Member
 
Join Date: Jul 2007
Posts: 36
Rep Power: 0
boy22 is on a distinguished road
Default
check this code:
Code:
private void IngresarActionPerformed(java.awt.event.ActionEvent evt) {                                         
    Connection conexion;
    Statement sentencia;
    
    try{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    }
     catch (Exception e){
    System.out.println("No se pudo conectar con el JDBC-ODBC");      
     return;
    }  
    
    try{
PreparedStatement insertar= con.prepareStatement("insert into table values( ? , ?,?,?,?,?,?)");
insertar.setString(1,"Marito");
insertar.setString(2,"Rojas");
insertar.setInt(3,45123145);
insertar.setDate(4,2007/5/2);
insertar.setDouble(5,1800.2);
insertar.executeUpdate();
    }   
catch( Exception e ) {
         System.out.println( e );
         return;
         }
    }
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
passing values from main page to pop up window vicky JavaServer Pages (JSP) and JSTL 4 12-29-2008 04:06 PM
Accessing boolean Values of another values in one class. a_iyer20 Advanced Java 4 04-15-2008 02:04 PM
passing dynamically generated values abhiN Advanced Java 1 01-20-2008 04:21 AM
passing an array into an instance lockmac New To Java 1 08-08-2007 10:35 AM
Passing a value.. Lagarto New To Java 0 08-01-2007 05:32 PM


All times are GMT +2. The time now is 01:34 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org