|
-
Nov 20th, 2006, 04:34 PM
#1
Thread Starter
Frenzied Member
cant get Java code to work
Hello
My JDBCDemo class code is
Code:
public class JDBCDemo {
Connection db_connection;
Statement db_statement;
ResultSet result;
}
and it is not importing the required libraries which define Connection, Statement, Resultset.
I guess these are all javaclasses, if they are, is there any way to find which libraries they are located in, so that i may add the required libraries? is there any way i can add the rt.jar to JDBCDemo.java, or is that not possible
i tried to compile JDBCDemo.java and it came up with the following
C:\JDBCApp>javac JDBCDemo.java
JDBCDemo.java:2: cannot resolve symbol
symbol : class Connection
location: class JDBCDemo
Connection db_connection;
^
JDBCDemo.java:3: cannot resolve symbol
symbol : class Statement
location: class JDBCDemo
Statement db_statement;
^
JDBCDemo.java:4: cannot resolve symbol
symbol : class ResultSet
location: class JDBCDemo
ResultSet result;
^
3 errors
C:\JDBCApp>
-
Nov 21st, 2006, 04:23 AM
#2
Re: cant get Java code to work
Have you included
Code:
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
at the start top of the file?
-
Nov 21st, 2006, 04:41 PM
#3
Re: cant get Java code to work
 Originally Posted by vb_student
I guess these are all javaclasses,
Obviously ...
if they are, is there any way to find which libraries they are located in, so that i may add the required libraries?
Well, how did you learn about them? That tells you in which package they are. Once you know that, you can search for their fully qualified name to find out what they're part of.
Of course, since they're all from java.sql, they're all part of the standard distribution, so there's nothing you need to add.
is there any way i can add the rt.jar to JDBCDemo.java, or is that not possible
rt.jar is always in the classpath, unless you override the boot classpath.
i tried to compile JDBCDemo.java and it came up with the following
C:\JDBCApp>javac JDBCDemo.java
JDBCDemo.java:2: cannot resolve symbol
symbol : class Connection
location: class JDBCDemo
Connection db_connection;
^
The compiler is looking for a class Connection. This should tell you that something is wrong: you're using JDBC, so it should be looking for java.sql.Connection. In other words, you need to either fully qualify the name (i.e. use java.sql.Connection whereever you use Connection now) or tell the compiler that you really mean java.sql.Connection whenever you say Connection. That's what the import statement is for.
See DeadEyes' post for the actual specific solution to your problem.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 1st, 2006, 07:28 PM
#4
Thread Starter
Frenzied Member
Re: cant get Java code to work
thanks for the response dude,
it makes sense
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|