Question in including lib? or else? [message #298247] |
Thu, 26 January 2006 20:47 |
Eclipse User |
|
|
|
Originally posted by: happyniu1985.hotmail.com
I'm a student now migrating from .net to java platform. I have to learn
how to use java to build dynamic website and web services before end of
this winter vacation T_T. It'll be a hard work since I know nothing about
java except it's name.
But it's really funny to learn java, although sometime frustrating.
Here comes a problem when I tried to use the mysql connector/j to
communicate with the mysql server.
The problem comes twice, i'll describe them.
Here's my platform, I installed them in the listed scequence:
Windows XP SP2(newly installed), jre-1_5_0_06-windows-i586-p.exe,
jdk-1_5_0_06-nb-4_1-win-ml.exe, j2eesdk-1_4_02_2005Q2-windows.exe,
jwsdp-2_0-windows-i586.exe, apache-tomcat-5.5.12.exe,
mysql-5.0.18-win32.zip, mysql-administrator-1.1.7-win.msi,
mysql-query-browser-1.1.19-win.msi, wtp-all-in-one-sdk-1.0-win32.zip
I know it's funny, but since i know nothing about java, i just install
everything i may need and i've heard. And I just run the executable files
to set up them but I didn't config any enviroment variables, but every
things goes well until the following problems accured. By the way, I
installed all the program into F:\JoyJava\ except Windows, and change the
"java/installed jres" to point at F:\JoyJava\Java\jdk1.5.0_06, "java/build
path" to "Folders" of the eclipse preferences.
1st:
I was learning how to use jsp and javabean.
I copied the mysql-connector-java-3.1.12-bin.jar to web-inf\lib, and
eclipse detected it.
When I tried jsp + mysql, everything is ok
(index.jsp)
...
<table>
<%
...
Class.forName("com.mysql.jdbc.Driver"); // Runs well
Connection con =
DriverManager.getConnection("jdbc:mysql://127.0.0.1/testbase?user=test&password=test");
...
%>
</table>
...
But when i tried jsp + javabean + mysql, there comes the problem:
(index.jsp)
...
<jsp:useBean id="tb" class="testsite.TestBase" scope="page" />
...
(src\testsite\TestBase.java)
package testsite
public class TestBase
{
public TestBase()
{
Class.forName("com.mysql.jdbc.Driver"); // ClassNotFoundException
...
}
}
I don't know why, so i build a java application for another test, then
comes the second times.
2nd:
I created a new java project, just a HelloWorld application.
This time I create a lib folder manually and set the "Java Build
Path/Libraries" to add the lib class folder.
(TestClass.java)
package testbase
public class TestClass
{
public static void main(String[] args)
{
Class.forName("com.mysql.jdbc.Driver"); // Still ClassNotFoundException;
}
}
I guess it's a lib problem, maybe java vm can't the mysql lib, but it did
work in jsp files.
You know in .net it's really easy to include a lib into a project, is it
still easy in java?
So please help me, or I'll be really in trouble when the new tearm start.
Thanks a lot.
|
|
|
Powered by
FUDForum. Page generated in 0.02101 seconds