Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

error in sql server 7.0 connection

0 views
Skip to first unread message

Guru

unread,
Dec 5, 2001, 9:45:24 PM12/5/01
to
Hello Everybody,
I have written a code to access a SQL server database.I am
using data source as smguru. I have given lot of prnt
statements to check whether everything is working fine.The
program is throwing exception from the executequery line.
I don't know what is wrong.I have attach the exception
also. Please help me in this matter.Help is greatly
appreciated.

Regards
Guru
public void databaseconnection()
{
System.out.println("enter database connection");
String data ="jdbc:odbc:smguru";

try {
System.out.println("inside try block");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("enter database connection1");
Connection con = DriverManager.getConnection
(data,"xx","xxxxxx");
if(con.equals(con))
{
System.out.println("connection is correct");
}
System.out.println("enter database connection2");
Statement st = con.createStatement();
System.out.println("enter database connection3");
ResultSet rec = st.executeQuery("SELECT * FROM
tblPathSite");
System.out.println("enter database connection4");
if(rec.wasNull())
{
System.out.println("record is null");
}
while(rec.next())
{
System.out.println(rec.getString("PathID")+ "," +
rec.getString("SiteID"));
}
st.close();
}catch(SQLException sqlexc){sqlexc.printStackTrace();}
catch(Exception ex){ }

}


java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]
[SQL Server]Invalid
object name 'tblPathSite'.
at sun.jdbc.odbc.JdbcOdbc.createSQLException
(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown
Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown
Source)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown
Source)
at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery
(Unknown Source)
at hospital.cPDetails.databaseconnection
(cPDetails.java:984)
at
hospital.Cmainframe$ActionHandlermainframe.actionPerformed
(Cmainf
.java:168)
at javax.swing.AbstractButton.fireActionPerformed
(Unknown Source)
at
javax.swing.AbstractButton$ForwardActionEvents.actionPerfor
med(Un
n Source)
at
javax.swing.DefaultButtonModel.fireActionPerformed(Unknown
Source
at javax.swing.DefaultButtonModel.setPressed
(Unknown Source)
at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased
(Unknown
ce)
at java.awt.Component.processMouseEvent(Unknown
Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown
Source)
at java.awt.Container.dispatchEventImpl(Unknown
Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Unknown
Source)
at java.awt.LightweightDispatcher.processMouseEvent
(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent
(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown
Source)
at java.awt.Window.dispatchEventImpl(Unknown
Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown
Source)
at java.awt.EventDispatchThread.pumpOneEvent
(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown
Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Joseph Weinstein

unread,
Dec 6, 2001, 2:43:22 PM12/6/01
to Guru
Hi. The problem may be that the table you're referring to
is either in a different database in the same MS SQLServer
instance, and/or it was made by a different user than
you are logging in as. Let's assume the table is in 'master',
and it was made by user 'john'. You should be able to see it
regardless of who you log in as, (if your user has permissions)
if you fully specifiy the table name as 'master.john.tblPathSite'.
Joe
0 new messages