sharad bhai

Greenhorn
+ Follow
since Jun 25, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sharad bhai

I have a directory structure

ch03/
registration.jsp
registationform.html
welcome.jsp
WEB-INF/
errorPage.jsp
footer.jsp
web.xml
classes/
ch03
FaqCategories.java
FaqCategories.class
User.java
User.class

While putting it exactly into TOMCAT in the above manner, I get the following error

Jul 20, 2004 4:29:04 PM org.apache.jasper.compiler.Compiler generateClass
SEVERE: Error compiling file: X:\jakarta-tomcat-5.0.12\work\Catalina\localhost\c
h03\org\apache\jsp\welcome_jsp.java [javac] Compiling 1 source file

X:\jakarta-tomcat-5.0.12\work\Catalina\localhost\ch03\org\apache\jsp\welcome_jsp
.java:90: illegal start of expression
>
^
X:\jakarta-tomcat-5.0.12\work\Catalina\localhost\ch03\org\apache\jsp\welcome_jsp
.java:91: ';' expected
}
^

Where do I start searching for the error??? In the .jsp file or the .java files. I searched for in both places and found nothing. All my files are a max of 50 lines of code, so where the line 91??
17 years ago
JSP
Could someone please reply to this. I would really appreciate this. I really need this connection to work. Thanks.
First of all I had classes12.zip in my class path instead of classes12.jar. Got past the first line. Mdified the program as under

import java.sql.*;
import oracle.jdbc.*;

public class trial2{
public static void main(String args[])
{
Connection conn=null;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("JDBC Driver Loaded");
String username = "system";
String password = "sys";
conn=DriverManager.getConnection("jdbc racle:thin:@<IP address>:5560:COFFEEBREAK",username,password);
System.out.println("Connecting to Database");
}
catch (SQLException e){
System.err.println("SQL state: " + e.getSQLState());
System.err.println("SQL error: " + e.getErrorCode());
e.printStackTrace();
}
catch(Exception e)
{
System.out.println("Error ---> " + e.getMessage());
}
finally{
try
{
if (conn != null)
conn.close();
}
catch (Exception ignoreThis)
{
}
}
}
}

I get the following error message


JDBC Driver Loaded
SQL state: null
SQL error: 17002
java.sql.SQLException: Io exception: Bad packet type
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:124)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:161)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
:273)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:318)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:
343)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:147)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtensio
n.java:31)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:545)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at trial2.main(trial2.java:14)
Press any key to continue...
Thanks. What I did was took your advice and modifed my code to catch a general Exception e. Then did a e.getMessage(). There is an error showing up saying oracle/jdbc/OracleDriver(). Any idea what this means??

I have just downloaded the classes12.zip file and added it to my d: drive in a folder I created called d:\orcldrv.

I have also seen that in many forums they talk about CLASSPATH. I looked up my environment varialbes and could not find a CLASSPATH listed there. Any ideas...
import java.sql.*;

public class trial2{
public static void main(String args[])
{
try
{
Class.forName("oracle.jdbc.OracleDriver()");
Connection conn=DriverManager.getConnection("jdbc racle:thin:@URL,"USERNAME","PASSWORD");
}
catch(java.sql.SQLException e)
{
e.printStackTrace();
}
System.out.println("Connecting to Database");
}
}

I am getting the following error

unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown
Class.forName("oracle.jdbc.OracleDriver()");


I am absolutely new to JDBC and this is my first code. Absolutely no idea why this happens