 |
 |
JDBC connection between Tomcat (JSP) & MySQL
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Mar 2001
Location: London, UK & Pittsburgh, USA
Status:
Offline
|
|
Anybody got a step by step to access a MySQL database via Tomcat. Or put another way, is there a JDBC driver for MySQL for OSX?
TIA,
------------------
- David Kephart
ICQ: 19510117
AIM: TheKephart
|
|
- David Kephart
ICQ: 19510117
AIM: TheKephart
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Sep 2000
Location: San Francisco
Status:
Offline
|
|
At last visit they hadn't updated their instructions from the Public Beta, but you might find what you want at the aptly-named
http://www.JSPforMacs.com/
------------------
Since EBCDIC
Make every post count!
|
|
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Feb 2000
Location: Chicago, IL
Status:
Offline
|
|
I don't know if it will run on OSX, but I would think it would since it is just a set of java classes. I've used it for writing servlets with some success before.
http://www.voicenet.com/~zellert/tjFM
|
|
|
| |
|
|
|
 |
|
 |
|
powert
|
|
Access MySQL through JDBC in the normal manner you would on any platform with the normal JDBC driver mm* (find it on the mysql website).
It is java after all...
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Mar 2001
Location: London, UK & Pittsburgh, USA
Status:
Offline
|
|
I tried the mm mySQl JDBC drivers under public beta to no avail... anyone actually have this working on osx? Step by step would be greatly appreciated...
cheers,
-david
|
|
- David Kephart
ICQ: 19510117
AIM: TheKephart
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2001
Location: brooklyn, ny
Status:
Offline
|
|
I have been trying the same with no success. I have jakarta-tomcat working and i have mysql working but i cannot get the driver (org.gjt.mm.mysql.Driver) to load. I get a classNotFound exception. I placed the driver files alongside classes.jar but this didn't work. I tried setting the classpath but i'm not sure i have the syntax right. i've seen a couple different examples. i even tried adding the files into the classes.jar but still no success. I do have two examples of .jsp files that in theory should work with mysql. i can email them to anyone interested. I'll keep plugging away and watch this thread for any news.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2001
Location: brooklyn, ny
Status:
Offline
|
|
I got Mysql and jakarta-tomcat working on Mac OS X last night. here is a general step by step for the novice.
1. install the binary jakarta-tomcat release version. www.jspformacs.com has an installation tutorial.
2.install the pkg version of Mysql http://www-u.life.uiuc.edu/~mwvaugh/MacOSX/Packages/
3. get the jdbc driver from http://www.worldserver.com/mm.mysql/
3.a uncompress it and put the "org" folder somewhere in your CLASSPATH.
-- I put mine in /System/Library/java and set the CLASSPATH by creating a .tcshrc file in my home directory with the first entry being setenv CLASSPATH /System/Library/java/org
4. Set up Mysql and a database using the Mysql manual.
5. Using a JSP/Servlet book or online example create a jsp/servlet.
This is an overview of what worked for me.
|
|
|
| |
|
|
|
 |
|
 |
|
powert
|
|
With respect I know lots of people including myself who were perfectly able to use it on PB.
Please don't unbundle the tar. Just put it in your classpath... the tutorial should be enough to enable you to create a java class to connect. There's nothing specific to OS/X at all with this...
I've got MySQL with the latest mm JDBC 2 driver (2.0.4) working with EJBs and transactions using MySQL 3.23.36 (now available, compiled --with-berkeley-db), and using table type BDB.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Mar 2001
Status:
Offline
|
|
Yes, JDBC + MySQL is fairly easy to configure.
I've easily compiled and installed MySQL on MacOS X. Even with the Berkeley DB support compiled in.
My problem is that I can't seem to start MySQL without the '--skip-bdb' flag so i get no BDB. If I don't disable BDB, MySQL fails to load stating that the OS doesn't support fast mutexes or something like that.
(BTW I didn't explicitly state '--with-berkeley-db' in compilation, but isn't that compiled in by default?
Thanx in advance,
Daniel++
|
|
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Feb 2000
Location: Chicago, IL
Status:
Offline
|
|
I have to admit I'm having some problems here. I've used these components before to write/compile/run code on a remote server, but I've never had to configure the installation.
I did as brooklyn_mac_guy suggests. I've tried both the jar and the uncompressed class directories placed in the /system/library/java directory and I've set the CLASSPATH appropriately. But when I try to execute the code from Forte4J, I get "no suitable driver" exceptions.
Here is the essential part of the code I've writen/plagerized
import java.sql.*;
import java.lang.*;
import java.util.*;
import java.net.*;
import java.io.*;
public class LoadDataApp {
public static void main(String args[])
throws IOException
{
int reslt;
String username = "username";
String password = "password";
String dbasename = "database";
String SQLstatement = "null";
String tableName = "table";
//-----------------------------
try {Class.forName("org.gjt.mm.mysql.Driver").newInsta nce();}
catch(Exception e){System.out.println( "Error DriverMgr: " + e + "<br>" );}
//-----------------------------
Connection con = null;
String url = "jdbc:mysql:";
try {con = DriverManager.getConnection(url + dbasename, username, password);}
catch(SQLException se){System.out.println( "Error DriverMgr: " + se + "<br>" );}
//-----------------------------
try {
Statement statmt = con.createStatement();
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(InputFile)));
//some other stuff here
statmt.close();
con.close();
}
// catch(SQLException se)
catch(Exception e)
{
// sout.println( "Error SQL: " + se + "<br>" );
System.out.println( "Error IO: " + e + "<br>" );
}
//----------------------------------------
// close connection
try {con.close(); }
catch(SQLException se){System.out.println(se);}
//-----------------------------------
}
}
Here's the error message when I try to run from ProjectBuilder
Error DriverMgr: java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver<br>
Error DriverMgr: java.sql.SQLException: No suitable driver<br>
Error IO: java.lang.NullPointerException<br>
[JavaAppLauncher Error] LoadDataApp.main(String[]) threw an exception:
java.lang.NullPointerException
at LoadDataApp.main(LoadDataApp.java:89)
at java.lang.reflect.Method.invoke(Native Method)
at com.apple.buckyball.app.CarbonLibApp$MainRunner.ru n(CarbonLibApp.java)
at java.lang.Thread.run(Thread.java:496)
[This message has been edited by mcdoken (edited 04-25-2001).]
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2001
Location: brooklyn, ny
Status:
Offline
|
|
The whole classpath is definitely a tricky thing for those of us unfamiliar with java on unix. You might want to double check your classpath setting by typing just "setenv" at the terminal prompt. As long as you're still using the default tcsh this should give you a list of enverinment variables. make sure the classpath is in there and correct. If you're using bash i think just "set" is the equivalent. You might also try compiling with javac. FWIW here is some of the code that worked for me.
String url = "jdbc:mysql://localhost/test_db?user=test_user&password=test_password" ;
Class.forName("org.gjt.mm.mysql.Driver");//It worked for me without newInstance()
Connection conn = DriverManager.getConnection(url);
This worked in a jsp page for me. I haven't tried to compile a servlet or anything else (applet, application) using jdbc yet.
good luck.
[This message has been edited by brooklyn_mac_guy (edited 04-25-2001).]
[This message has been edited by brooklyn_mac_guy (edited 04-25-2001).]
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|