🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.lenguajes.java
Article #776

Re: Problema al hacer consulta en SQL Server

#776
From: jc7o
Date: Fri, 09 Mar 2007 20:16
87 lines
4277 bytes
Puede ser que el nombre del usuario, digamos josé, con el que te
conectas no sea el owner de la tabla "usuarios" entonces si haces
SELECT * FROM usuarios
el intentará hacer el select sobre la tabla jose.usuarios y no la
encontrará porque jose no tiene una tabla llamada usuarios
Intenta poniendo anteponiendo el owner de la tabla en la consulta, por
ejemplo
SELCT * FROM dbo.usuarios
Otra cosa a verificar es que el usuario tenga permisos de lectura
sobre esa tabla.

Saludos,

Julio.-

On 8 mar, 16:10, "ivo" <ivanp...@gmail.com> wrote:
> 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: <1173471378.793464.114020@h3g2000cwc.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!h3g2000cwc.googlegroups.com!not-for-mail
References: <1173381009.006453.82580@j27g2000cwj.googlegroups.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1116f3,1ce5f7368eda2fb6
X-Google-Attributes: gid1116f3,public
X-Google-Language: SPANISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!h3g2000cwc.googlegroups.com!not-for-mail
From: "jc7o" <castillo.julio@gmail.com>
Newsgroups: es.comp.lenguajes.java
Subject: Re: Problema al hacer consulta en SQL Server
Date: 9 Mar 2007 12:16:18 -0800
Organization: http://groups.google.com
Lines: 89
Message-ID: <1173471378.793464.114020@h3g2000cwc.googlegroups.com>
References: <1173381009.006453.82580@j27g2000cwj.googlegroups.com>
NNTP-Posting-Host: 200.126.150.67
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1173471399 12691 127.0.0.1 (9 Mar 2007 20:16:39 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 9 Mar 2007 20:16:39 +0000 (UTC)
In-Reply-To: <1173381009.006453.82580@j27g2000cwj.googlegroups.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.2) Gecko/20061201 Firefox/2.0.0.2 (Ubuntu-feisty),gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: h3g2000cwc.googlegroups.com; posting-host=200.126.150.67;
   posting-account=4nMeXg0AAAByEiSv70hzOCgqI_XmUrMr