English 中文(简体)
连接mysql和tomcat?
原标题:Connecting mysql and tomcat?

嗨,我是tomcat和mysql的新手。

我已经在Ubuntu 9.10中安装了Tomcat和mysql,它们都运行得很好!!

But now I have task of connecting mysql and tomcat. I dont have any idea on this. However I looked some manuals but did not find any luck.

盖伊,请给我一个关于如何将mysql与tomcat连接的分步过程。

顺便说一句,我已经下载了mysql连接器,并将.jar文件复制到$CATALINA_HOME/lib

What else should I do ? Thanks!

@at0mzk This is the steps I followed to install tomcat http://www.linuxnix.com/2010/12/how-to-install-apache-tomcat-on-linuxredhatubuntu.html and I installed mysql server and client using the commands sudo apt-get install mysql-server mysql-client later I downloaded JDBC Driver for MySQL (Connector/J) from http://www.mysql.com/products/connector/ and extrated it and pasted the .jar file in /opt/apache-tomcat-6.0.29/lib ( I dont have $CATALINA_HOME/common/lib) . My questions are 1) Is the connection between tomcat and sql established ? 2) do i need to install mysql-server when I have tomcat server ?

问题回答

Which manual did you follow when installing? Should follow installation intructions in the Tomcat manual for your version. For example 5.5: http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html#MySQL_DBCP_Example

请注意,手册上写的是$CATALINA_HOME/common/lib,而不是$CATALINA_HOME/lib

“当我有tomcat服务器时,我需要安装mysql服务器吗”

首先,你需要mysql吗?我有很多使用替代数据库的网络应用程序,甚至是嵌入式数据库。运行Tomcat不需要Mysql。

“tomcat和sql之间的连接是否已建立”

其次,单独的web应用程序本身可以直接建立到mysql的连接。

正如at0mzk所指出的,我对设置Tomcat JNDI数据源的过程了解不多,因为我从未这样做过,但我怀疑这再次取决于单个应用程序来寻找该服务并使用它连接到数据库。不过,我可以说,您不一定需要它,这取决于您的应用程序需要什么。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签