Article View: es.comp.lenguajes.java
Article #771Problema al hacer consulta en SQL Server
From: ivo
Date: Thu, 08 Mar 2007 19:10
Date: Thu, 08 Mar 2007 19:10
71 lines
3388 bytes
3388 bytes
Tengo el siguiente mensaje de error:
Aqui Error getting Result SQLException:[Microsoft][SQLServer 2000
Driver for JDBC][SQLServer]El nombre de objeto 'usuarios' no es
vΓ‘lido.
SQLState: 42S02
VendorError: 208
ESTOY ACCESANDO A UNA TABLA DE SQL SERVER, LA DB ES "montero", LA
TABLE ES "usuarios", Y EL HOST ES "IVANPIMA", Y QUIERO RECUPERAR LA
INFORMACION DE ESA TABLA, MIS DECLARACIONES SON LAS SIGUIENTES
private Connection createConn (String db){
try{DriverManager.registerDriver(new
com.microsoft.jdbc.sqlserver.SQLServerDriver());
conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://
IVANPIMA:1433",user,pass);
}catch (SQLException ex){
// handle any errors
System.out.println("Error getting Connection SQLException:
" + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}catch (Exception er){
System.out.println(er.getMessage());
}
return conn;
}
public ResultSet getData(String db, String sql){
try{
if (conn==null)
conn = createConn(db);
if(conn!=null){
stmt = conn.createStatement();
rs =
stmt.executeQuery(sql);
}else{
rs = null;
}
}catch(SQLException e){
System.out.println("Aqui Error getting Result
SQLException: " + e.getMessage());
System.out.println("SQLState: " + e.getSQLState());
System.out.println("VendorError: " +
e.getErrorCode());
}catch(Exception er){
System.out.println(er.getMessage());
}
return rs;
}
Y DESDE AQUI LO MANDO LLAMAR
public String validarLogin(String usuar, String passw){
String query = "";
String nivelr = "";
query = "select usuario,pass,nivel from usuarios where usuario =
'"+usuar+"' and pass = '"+passw+"'";
System.out.println(query);
ResultSet validars = null;
try{
validars = conn.getData("montero",query);
if (validars.next()){
nivelr = validars.getString(3);
}
}catch (Exception er){System.out.println(er.getMessage());
}return nivelr;
}
Technical Details
Message-ID:
<1173381009.006453.82580@j27g2000cwj.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!j27g2000cwj.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 1116f3,1ce5f7368eda2fb6,start X-Google-Attributes: gid1116f3,public X-Google-Language: ENGLISH,ASCII Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!j27g2000cwj.googlegroups.com!not-for-mail From: "ivo" <ivanpima@gmail.com> Newsgroups: es.comp.lenguajes.java Subject: Problema al hacer consulta en SQL Server Date: 8 Mar 2007 11:10:09 -0800 Organization: http://groups.google.com Lines: 72 Message-ID: <1173381009.006453.82580@j27g2000cwj.googlegroups.com> NNTP-Posting-Host: 189.166.235.117 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1173381030 6191 127.0.0.1 (8 Mar 2007 19:10:30 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 8 Mar 2007 19:10:30 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: j27g2000cwj.googlegroups.com; posting-host=189.166.235.117; posting-account=I6zIPg0AAADaj4VF__0ZfyU7VHeyKy2g