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)