Error on Connection
Hello all
I have this nice chunk of code that is trying to connect to a database named Prueba. it compiles just fine, but it wont work properly.. here's the code.
package prueba;
import java.sql.*;
/**
*
* @author Administrator
*/
publicclass TestCon{
publicstaticvoid main(String args[]){
Connection conexion;
Statement sentencia;
ResultSet resultado;
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();
resultado = sentencia.executeQuery("SLECT * FROM Empleados");
while(resultado.next() ){
String Empleado_ID = resultado.getString("IDemp");
String Nombre = resultado.getString("Nombre");
String Apellido = resultado.getString("Apellido");
System.out.println("Empleado:" + Empleado_ID +" " + Nombre +" " + Apellido);
}
}
catch( Exception e ){
System.out.println( e );
return;
}
}
}
When i run this, Netbeans says:
init:
deps-jar:
compile-single:
run-single:
java.sql.SQLException: [Microsoft][SQL Native Client][SQL Server]Incorrect syntax near '*'.
BUILD SUCCESSFUL (total time: 1 second)
:-/

