chaitanya gopal

Greenhorn
+ Follow
since May 22, 2007
Merit badge: grant badges
For More
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 chaitanya gopal

Thank you for the reply paul,

i successfully connect to database using datasource-JdbcOdbcDriver
but i am trying to connect using OracleDriver it throws exception like:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:766)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
at jdbcapp.CreateDatabase.doGet(CreateDatabase.java:40)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)


i added ojdbc14.jar to tomcat/common/lib folder and its there within my application.

i don't understand why it can't recognize that class.


thanks,
chaitanya.
hi,
When i am trying to connect database using datasource it throws exception:

javax.servlet.ServletException: Cannot create JDBC driver of class '' for connect URL 'null'
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

i added context to the server.xml in tomcat/ conf folder.
<Context path="/JDBCProj" docBase="JDBCProj" debug="5" reloadable="true" crossContext="true">

<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
<Resource name="jdbc/dbconn" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/dbconn">
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@localhost:1521:orcl</value>
</parameter>
<parameter>
<name>username</name>
<value>scott</value>
</parameter>
<parameter>
<name>password</name>
<value>tiger</value>
</parameter>

</ResourceParams>
</Context>


and i added reference names to web.xml as
resource name: jdbc/dbconn
resource type: javax.sql.DataSource
auth: Container

code in my JSP is:
InitialContext ctx = new InitialContext();
DataSource ds =(javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/dbconn");
Connection conn = ds.getConnection();
why it throws exception?

thanks,
chaitanya.
Hi friends,
I am trying to load and connect to oracle driver like below... DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger");

It works fine in Netbeans IDE but Its not working in Eclipse, the same code.
In Eclipse it throws Exception like this:
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver FirstJdbc.doGet(FirstJdbc.java:23)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

I added ojdbc jar file for the library. and it has that OracleDriver class.
I must need to work on Eclipse IDE..Please let me know why?

Thanks,
Chaitanya.
Hi friends,

Is it possible to throw an exception without declaring at method declaration using throws keyword..?
I am asking about only exceptions[checked] not the [unchecked]runtime exceptions and the errors.

I am confusing about throws and throw..which one used in which situations..?please let me know guys...

thanks,
chaitanya.
Hi Alejandro,
its really weired , happened that to you..
I am also prepared to buy a voucher. you mentioned that the certification regular price , US$150. but in sun site it shows US$200.
i too heard from my friends who certified SCJP, that the price is US$150. were they changed the price or what i saw is wrong..?
let me know...

thanks,
Chaitanya.
Hi Chandra Bhatt,

I understand how it works when using static...
but i didn't get how it works when we delete static....

bcoz when derived class constructor calls the base class constructor,at that time it calls the derived class addValue() method instead of the base class addValue() method...why...will you explain it more clearly....

Thanks,
Chaitanya.
double d[][][] = new double [3][][];

here d holds three double[][] arrays.

ex:
d[0]=a[][];
d[1]=b[][];
d[2]=c[][];

got it..

chaitanya.
Thank you Raghavan,

you are correct, after setting my path it works fine...

thanks,
Chaitanya.
sorry friends,

its not a compile time error , its a runtime error as below:

D:\cnya\UnderBookRef>java Foo
Exception in thread "main" java.lang.UnsupportedClassVersionError: Foo (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)


thanks,
chaitanya.
class Bar
{
static int num=9;
}

class Foo
{
Bar b=new Bar();
void ChangeIt(Bar b)
{
b.num=23;
System.out.println("b.num in a method :"+b.num);
b=new Bar();
b.num=45;
System.out.println("b.num in a method now :"+b.num);
}
public static void main(String args[])
{
Foo f=new Foo();
System.out.println("f.b.num in main is:"+f.b.num);
f.ChangeIt(f.b);
System.out.println("f.b.num in main after ChangeIt is:"+f.b.num);
}
}

according to K&B it compiles fine and gives the output like below:
f.b.num in main is: 9
b.num in a method : 23
b.num in a method now : 45
f.b.num in main after ChangeIt is:23

but when i try to compile , it slaps me....
I am using jdk1.5 version.....

why it is....

thanks,
chaitanya.
Thanks Lynn, I read no.of books for this topic: Diff b/w checked and unchecked exceptions... but i didn't get the clear idea if you provide example for this,that's so helpful for me....
thanks,
chaitanya.
Hi friends,

I understand the unchecked exception, which are subclasses of RTE.
and we need not to maintain them. JVM will take care of them.
Am I correct and also anybody tell me abt checked exception?

and difference b/w throw and throws clause..?