Adaptando JFileChooser com insert mysql

Pessoal, estou tentando adaptar o jfilechooser com o meu insert no bd, se puderem me ajudar com dicas de onde estou errando agradeço.

import java.io.File;  
import java.io.IOException;  
import java.sql.Connection;  
import java.sql.DriverManager;  
import java.sql.PreparedStatement;  
import java.sql.SQLException;  
import java.util.Date;  
import org.apache.poi.ss.usermodel.Row;
import jxl.Cell;  
import jxl.DateCell;  
import jxl.NumberCell;  
import jxl.Sheet;  
import jxl.Workbook;  
import jxl.read.biff.BiffException;  
import javax.swing.JFileChooser;
 
 
public class Insert_xlsJava2 {  
   
    private static Connection conn;  
    private static int i = 0;
    private static String stringa1;  
    private static String stringa2;  
    private static String stringa3;  
    
    public static void main(String[] args ) 
    throws IOException, BiffException,ClassNotFoundException, SQLException {  
    
      JFileChooser arquivo = new JFileChooser();
      int retorno = arquivo.showOpenDialog(null);
      
    Class.forName("com.mysql.jdbc.Driver");  
    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/bd_hh_fixa","root","");    
     
    String caminhoArquivo = "";
     if(retorno == JFileChooser.APPROVE_OPTION){
       caminhoArquivo = arquivo.getSelectedFile().getAbsolutePath();
   
       Workbook workbook = Workbook.getWorkbook(new File("c:/arquivo.xls"));    
     Sheet sheet = workbook.getSheet(0);
 
     int linhas = sheet.getRows();  
    
      for(i = 0; i < linhas; i++){  
      Cell a1 = sheet.getCell(0,i); 
      Cell a2 = sheet.getCell(1,i); 
      Cell a3 = sheet.getCell(2,i); 
      stringa1 = a1.getContents();
      stringa2 = a2.getContents();
      stringa3 = a3.getContents();
      PreparedStatement ps = conn.prepareStatement("INSERT INTO teste(nome,prenome,sobrenome)" +
          "VALUES('"+stringa1+"','"+stringa2+"','"+stringa3+"')");  
           
     ps.executeUpdate();   
     }
      
    workbook.close();  
  
    }else{
     
   }
}
}

[quote=Helber]Pessoal, estou tentando adaptar o jfilechooser com o meu insert no bd, se puderem me ajudar com dicas de onde estou errando agradeço.
[/quote]

pq vc tbm não posta o ‘erro’ que aparece em seu console?
As vezes, só de olhar pra isso, já ajuda.

.

Pessoal problema resolvido, dei uma pesquisada no livro do deitel e conseguir fazer o bug. segue o codigo completo, espero que isso ajude a todos.


package br.exel;

import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
 
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
 
public class PesquisaArquivo {
 
      private static Connection conn;  
    private static int i = 0;  
    private static String stringa1, stringa2, stringa3;
      
      public static void main(String[] args)
      throws IOException, BiffException, ClassNotFoundException, SQLException{
            
           
            Class.forName("com.mysql.jdbc.Driver");  
          Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/bd_hh_fixa","root","");
                        
                   String caminhoArquivo = "";
           
            JFileChooser arquivo = new JFileChooser();
           
            int retorno = arquivo.showOpenDialog(null);
            
            
            if(retorno == JFileChooser.APPROVE_OPTION){
           
                  caminhoArquivo = arquivo.getSelectedFile().getAbsolutePath();
                  Workbook workbook = Workbook.getWorkbook(new File(caminhoArquivo));
                  
           
                  Sheet sheet = workbook.getSheet(0); 
           
                  int linhas = sheet.getRows();
                  for(i = 0; i < linhas; i++){  
           
                      Cell a1 = sheet.getCell(0,i);  
                      Cell b2 = sheet.getCell(1,i);  
                      Cell c3 = sheet.getCell(2,i);  
                    
                  
           
                      stringa1 = a1.getContents();  
                      stringa2 = b2.getContents();  
                      stringa3 = c3.getContents();  
                        
                    
                        
           
                     PreparedStatement ps = conn.prepareStatement("INSERT INTO teste(nome,prenome,sobrenome)" +
                          "VALUES('"+stringa1+"','"+stringa2+"','"+stringa3+"')");  
                           
                     ps.executeUpdate();   
                     } 
                  
           
            }else{
           
}
}
}