Xin các Pro Chỉ Giáo
Hello & Welcome to our community. Is this your first visit? Đăng Ký
Follow us on
Follow us on Facebook Follow us on Twitter Linked In Flickr Watch us on YouTube My Space Blogger
 
Kết quả 1 đến 4 của 4
  1. #1
    Moderator DNTmaster's Avatar
    Ngày tham gia
    Jun 2006
    Đang ở
    GameZone
    Bài viết
    932
    Thanks
    6
    Thanked 576 Times in 183 Posts

    Xin các Pro Chỉ Giáo

    Các bác có ai cài Sever chạy cùng MySQL không,nếu bác nào cài rồi mà xài chung với MySQL được có thể hướng dẫn sơ qua cho mình được không
    [Only registered and activated users can see links. ]

  2. #2
    Thành Viên
    Ngày tham gia
    May 2008
    Bài viết
    372
    Thanks
    0
    Thanked 7 Times in 5 Posts

    Ðề: Xin các Pro Chỉ Giáo

    Tham khảo thêm ở đây nha bạn:[Only registered and activated users can see links. ] chúc bạn thành công!
    Khách viếng thăm hãy cùng Lovepw xây dựng diễn đàn CLBGAMESVN vững mạnh nhé!

  3. #3
    Moderator DNTmaster's Avatar
    Ngày tham gia
    Jun 2006
    Đang ở
    GameZone
    Bài viết
    932
    Thanks
    6
    Thanked 576 Times in 183 Posts

    Ðề: Xin các Pro Chỉ Giáo

    web bác đưa mình vào hok được bác ơi
    [Only registered and activated users can see links. ]

  4. #4
    Thành Viên
    Ngày tham gia
    Sep 2009
    Bài viết
    131
    Thanks
    5
    Thanked 17 Times in 4 Posts

    Ðề: Xin các Pro Chỉ Giáo

    Trích dẫn Gửi bởi DNTmaster [Only registered and activated users can see links. ]
    web bác đưa mình vào hok được bác ơi
    trích lại:

    Configuring a MySQL Data source in tomcat 4.1.31


    This article tells how to configure a MySQL data source in Tomcat 4.1 server. This article assumes that you have installed the proper versions of MySQL and tomcat. Here we assume that you have installed Tomcat to C:\Tomcat. The name of web application that we are going to configure is Test. The JNDI name used for configuring the data source id jdbc/Test.

    System Requirements
    Apache tomcat 4.1.31
    MySQL
    Ensure that you have the following files in your lib folder.
    commons-collections.jar
    commons-dbcp-xx.jar
    commons-logging-api.jar
    commons-pool-xx.jar

    naming-common.jar

    naming-factory.jar

    naming-resources.jar


    Download and Install drivers
    Download the MySQL 3.12 JDBC driver from [Only registered and activated users can see links. ]
    Unpack the file you have downloaded.
    Copy mysql-connector-java-xxxxx.jar file into the common/lib directory of your Tomcat installation directory. Not to your web application's lib directory.


    Shut down Tomcat
    Run bin/shutdown.sh or bin/shutdown.bat to shut down Tomcat.

    Edit server.xml
    Edit the conf/server.xml file in your Tomcat installation.
    Find the lines starting with <Host ...>
    Directly after this tag add these lines


    <Context className="org.apache.catalina.core.StandardContex t" cachingAllowed="false" charsetMapperClass="org.apache.catalina.util.Chars etMapper" cookies="true" crossContext="false" debug="0" docBase="C:\Tomcat\webapps\Test" mapperClass="org.apache.catalina.core.StandardCont extMapper" path="/Test" privileged="false" reloadable="true" swallowOutput="false" useNaming="true" workDir="work\Standalone\localhost\Test" wrapperClass="org.apache.catalina.core.StandardWra pper">

    <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_test_log." suffix=".txt" timestamp="true"/>

    <Resource auth="Container" description="Tomcat-MySQL Test" name="jdbc/Test" scope="Shareable" type="javax.sql.DataSource"/>

    <ResourceParams name="jdbc/Test">
    <parameter>
    <name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFact ory</value>
    </parameter>

    <parameter>
    <name>maxActive</name>
    <value>20</value>
    </parameter>

    <parameter>
    <name>maxIdle</name>
    <value>30000</value>
    </parameter>

    <parameter>
    <name>maxWait</name>
    <value>100</value>
    </parameter>

    <parameter>
    <name>username</name>
    <value>root</value>
    </parameter>

    <parameter>
    <name>password</name>
    <value>*********</value>
    </parameter>

    <parameter>
    <name>driverClassName</name>
    <value>com.mysql.jdbc.Driver</value>
    </parameter>

    <parameter>
    <name>url</name>
    <value>jdbc:mysql://localhost:3306/testdb?autoReconnect=true</value>
    </parameter>

    </ResourceParams>
    </Context>



    Where maxActive is the maximum number of database connections in pool. Setting this value to zero means no limit. maxIdle is the maximum number of idle connections in pool. maxWait is the maximum time to wait for a database connection to become available in ms, An Exception is thrown if this timeout is exceeded. A value -1 means waiting indefinitely. username and password is the username and password to connect to MySQL database. url is the JDBC connection URL. Replace the values with the correct parameters to connect to database.

    Configure web application (web.xml configuration).
    Edit Test/WEB-INF/web.xml. Add the following lines just before </web-app>


    <resource-ref>
    <description>Tomcat- MySQL Test</description>
    <res-ref-name>jdbc/Test</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>


    Test Code
    Create a jsp file to test our database connection.

    javax.naming.Context ctx = new javax.naming.InitialContext();
    javax.sql.DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/Test");
    java.sql.Connection con = ds.getConnection();

    out.println("Successfully connected to MySQL Database.");


    Restart Tomcat
    Run bin/startup.sh or bin/startup.bat to start Tomcat with the new settings.


    Now you can execute your code.

    Note: When starting Tomcat, if your console just vanishing away, make sure that you don't have a context with the name 'Test' already defined. If you are getting a ServletException 'javax.servlet.ServletException: Cannot create JDBC driver of class '' for connect URL 'null', cause: No suitable driver', please recheck your server.xml. Still if you are unable to connect to the database, please contact us indicating the error messages you are getting.
    Khách viếng thăm hãy cùng dung059 xây dựng diễn đàn CLBGAMESVN vững mạnh nhé!

 

 

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •  
Múi giờ GMT +7. Bây giờ là 04:45 AM.
vBulletin®, Copyright ©2000-2011, Jelsoft Enterprises Ltd.
CLBGamesVN không chịu trách nhiệm về Luật Bản Quyền của các tài liệu, bài viết v.v...được đăng tải trên diễn đàn này.
Diễn đàn phát triển dưới sự đóng góp của tất cả thành viên. BQT chỉ là những người thành lập ra sân chơi, quản lý và duy trì về mặt kỹ thuật, nội dung khi hợp lệ.