This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!

Ajit Sawant

Ranch Hand
+ Follow
since Nov 26, 2008
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 Ajit Sawant

Hello,

I tried running the basic form.html as per Head First SCWCD (Page 77). The step4 instructs to put web.xml under ../WEB-INF to test form.html. But with web.xml in place, Apache Tomcat(7.0.23) gives the following error

type Status report

message /Beer-v1/form.html

description The requested resource (/Beer-v1/form.html) is not available.
--------------------------------------------------------------------------------------
When I delete the file web.xml (not directory WEN-INF), it works fine. The page can be accessed.

Is it because the resource requested is .html and Apcache Tomcat's Web Server doesn't need web.xml but if it is available it fails to access the html resource?
Can somebody please explain this?

Thanks,
Ajit
I'm able to the server wwdcssofd01. ping comes back with
Reply from 10.25.248.143: bytes=32 time=197ms TTL=245
Reply from 10.25.248.143: bytes=32 time=223ms TTL=245
Her'e the code.
I tried following 2 combition one each with ojdbc5.jar and ojdbc6.jar, I got the error for both.
Jdk 6 Jdbc: ojdbc5.jar Database : Oracle 10.2.0.4
Error
Exception in thread "main" java.sql.SQLException: Io exception: Unknown host specified
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:441)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at testjdbc.main(testjdbc.java:11)


Jdk 6 Jdbc: ojdbc6.jar Database : Oracle 10.2.0.4
Error:
Exception in thread "main" java.sql.SQLException: Unknown host specified
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.jva:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java33)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:480)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:413)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java508)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtensin.java:33)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:510)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at testjdbc.main(testjdbc.java:11)
Caused by: oracle.net.ns.NetException: Unknown host specified
at oracle.net.resolver.HostnameNamingAdapter.resolve(HostnameNamingAdaper.java:187)
at oracle.net.resolver.NameResolver.resolveName(NameResolver.java:130)
at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:403)
at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:630)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:206)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:966)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:292)
... 7 more

Any suggestions?
Thanks,
Ajit
Hello,

I have JDK 6 and database Oracle 10g (10.2.0.4) for which I need a jdbc driver. I checked oracle website. The JDBC driver for JDK 1.6 is for 11g only
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_111060.html
And 10g support JDK 1.5 JDBC driver.
http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_10201.html
Is there any workaround for me to able to use JDK 6 and 10g for JDBC?
I have JDK 1.5 also on my machine. What should do to make my current JDK to be 1.5. This will at least let me use JDBC.

Thanks in advance.
Ajit
In your opinion you 'miserably failed' and you think the concept would be required in learning and understanding other chapters then I would repeat it.
Thanks,
Ajit
Hello,
I'm geting the following error message when trying to connect to Oracle database.

Exception in thread "main" java.sql.SQLException: Io exception: Unknown host specified
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:441)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at testjdbc.main(testjdbc.java:22)
--
Thanks,
Ajit
It is working fine. I put the *.jar file in ...\lib\ext. But I'm another error. I'll open a new thread for that.
Program failes to compile with message
testjdbc.java:9: package oracle.jdbc.driver does not exist
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
^
I have dowloaded jdbc driver ojdbc14.jar and it in my program's directory where I'm running javac command.. The current CLASSPATH IS: .;F:\myjava
I'm trying to test JDBC connection, but I geting errors for two tdrivers that I'm trying to load
1) DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
The above fails to compile with error
testjdbc.java:9: package oracle.jdbc.driver does not exist
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
^
1 error
2) DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
The above compiles with warning and when run give the error
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:oracle:thin@url
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at testjdbc.main(testjdbc.java:21)
--
For above 2 scenacios, tried with the below connections separately.
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@url",user,pwd);
Connection conn = DriverManager.getConnection ("jdbc:oracle:oci:@url",user,pwd);

Please advise.
Thanks,
Ajit
Concept: The initalization of the variable happen in the order in which the variable appear.
In this case when j is initialized the value of i is initialized to 0.
Concept that is being show is that at the time of object creation initializwer are executed and that the super class intializer in run before the subclass. Actually the intializer is run before it own constructor is run.

Ajit
On page 217 (chapter 3), part of the code is as follow:
class Foo{
static int size=7;
.... rest of the code.
The description on the page calls the variable size as an instance variable instead of static.
Hello All,
Its almost a year that I joined javaranch. And finally after start-stop-restart...., I cleared SCJP 6 last Monday. I scored 85%. Going into the, I was counting on OO and Concurrency, but didn't score well. As expected, I scored low for Collections and Generics. I'll revisit these topics just to feel good before I take to the next step. I had a scary moment during the exam as the drag-n-drop wasn't working for me. Also, for a question that required to choose 2 answers did not have check box but had radio button instead. For preparation, I used SCJP 6 by K&B and SCJP 6 by Kogent Solutions and links that I found here. Javranch has been the single best source of information and my biggest motivator has been the certification results page, so much that I made it my home page.
Best of luck to all future SCJP aspirants.
Thank you all ranchers!
Ajit
9 years ago
Q1: The following 3 options will work.(regardless of synchronized comm() ). But which object instance is locked?
Option1:public synchronized void run(){
This will lock the object test.
Option2:public void run(){
synchronized(x){
for (int i = 0; i<10; i++){
This will lock the object instance x.
Option3: public void run(){
synchronized(this){
for (int i = 0; i<10; i++){
This will lock the object test.
-----------------
Q2:If Thread.currentThread() returns current thread should this same as option3 above (using this)?
Q3:Ruben in your response "the MultiUseMe instance referred to by x (do synchronized(this)"-How can you get lock on object instance x by using 'do synchronized(this)'?