vendredi 27 février 2015

Java - Declared string



im trying to test a Java connection with ODB, but im having troubles, java is showing me like if i dont have declare the variable "ruta"



/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package conexion;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
*
* @author cr4id3r
*/
public class connect {
private Connection conexion;
public Statement sentencia;

public void conectarBasedeDatos(){
try{
final String CONTROLADOR = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName( CONTROLADOR );
final String rutas = "jdbc:odbc:Driver={Microsoft Acces Driver(*.mdb)};DBQ="+
System.getProperty("user_dir")+"/db/base.odb";
conexion = DriverManager.getConnection(rutas);
sentencia = conexion.createStatement();
}

catch(ClassNotFoundException ex1){
ex1.printStackTrace();
javax.swing.JOptionPane.showMessageDialog(null, "Error en creacion de statement");
System.exit(1);
}
}
}


Anyone know why it is? Thanks :)




Aucun commentaire:

Enregistrer un commentaire