2011-08-04 6 views
5

से कनेक्ट नहीं है, मैं अपने tomcat सर्वर को पुनर्स्थापित करने का प्रयास कर रहा हूं, लेकिन यह एप्लिकेशन है जो MySQL से ठीक से कनेक्ट नहीं होता है।टॉमकैट पर तैनात जावा एप्लिकेशन jdbc-mysql

यहाँ क्या हो रहा है है:

मैं एक जावा + फ्लेक्स आवेदन किया था। पूरा आवेदन एक निर्देशिका में रखा गया था (एक .war फ़ाइल नहीं)।

<database> 
      <rpgByMoodle user="moodle" password="moodle"> 
        <url>jdbc:mysql://localhost:3306/rpgbymoodle</url> 
      </rpgByMoodle> 
      <moodle user="moodle" password="moodle"> 
        <url>jdbc:mysql://localhost:3306/moodle</url> 
      </moodle> 
    </database> 

तो, मैं कमांड लाइन ग्राहक के माध्यम से mysql कनेक्ट करने में सक्षम हूँ, लेकिन आवेदन नहीं है:

$TOMCAT_WEBAPP/myflex_app/WEB-INF/lib/ -> JDBC mysql driver goes here. 

यहाँ अपने आवेदन config है।

मैंने कुछ नेटबीन्स (या ग्रहण) मेनू का उपयोग करके इंटरनेट कनेक्शन पर "नया कनेक्शन जोड़ने" के बारे में बताया .. लेकिन, मुझे एप्लिकेशन के स्रोत कोड तक पहुंच नहीं है।

मैं लिनक्स पर टॉमकैट चला रहा हूं। मैंने /var/log/tomcat6/ पर टॉमकैट लॉग फ़ाइल की जांच की है और jdbc के बारे में कुछ भी नहीं मिला है।

मेरे Catalina लॉग:

Aug 4, 2011 9:24:25 AM org.apache.catalina.core.StandardEngine start 
INFO: Starting Servlet Engine: Apache Tomcat/6.0.20 
Aug 4, 2011 9:24:26 AM org.apache.coyote.http11.Http11Protocol start 
INFO: Starting Coyote HTTP/1.1 on http-8080 
Aug 4, 2011 9:24:26 AM org.apache.catalina.startup.Catalina start 
INFO: Server startup in 977 ms 
+0

स्टैकट्रैक क्या है? अपना स्वयं का कनेक्शन प्रबंधन बनाने के बजाय जेएनडीआई और डेटासोर्स का उपयोग करने पर विचार करें। –

+0

@ माइकल-ओ क्षमा करें, मेरे पास स्रोत कोड तक पहुंच नहीं है।मुझे पता है कि जब मैं एप्लिकेशन चलाता हूं तो एक उपयोगकर्ता संदेश होता है "कनेक्शन विफल हुआ, व्यवस्थापक से संपर्क करें"। यदि आप मुझे स्टैकट्रैक या किसी भी लॉग फ़ाइल को खोजने में मदद कर सकते हैं जो मदद करता है ... –

+0

catalina.out और 'logs' में अन्य फ़ाइलों को जांचें। यदि कुछ भी नहीं है, तो आप भाग्य से बाहर हैं :-(यह एक काला बॉक्स प्रतीत होता है। –

उत्तर

4

tomcat-dir/common/lib में JDBC जार फ़ाइल डाल की कोशिश करो और बिलाव को पुनरारंभ करें।
प्रश्न Managing libraries in Tomcat की तुलना करें।

यदि इससे भी अब, काम करता है बिलाव लॉग फ़ाइल से निकालने के बाद, कनेक्शन नहीं JDBC कीवर्ड के रूप में की तलाश में।

+0

एंड्रियास, lib फ़ाइलों की प्रतिलिपि बनाएँ निर्देशिका 'tomcat-dir/lib' पर काम नहीं करता है। मैं टॉमकैट लॉग की जांच करता हूं और जो कुछ मुझे मिला वह कुछ नीति त्रुटियां थीं, कि मैं सभी नीति फ़ाइलों के लिए' अनुमति java.security.AllPermission; 'सेटिंग को ठीक करता हूं। अब, मैं पूरी तरह से अंधा हूं। लॉग फाइलें कुछ भी नहीं दिखाती हैं, कोई त्रुटि। –

+0

ओपी टॉमकैट 6 का उपयोग कर रहा है। जो फ़ोल्डर आप सुझा रहे हैं वह टॉमकैट 5.5 या उससे अधिक के लिए विशिष्ट है। – BalusC

3

मुझे पहले एक ही समस्या थी और इसे हल करने में कामयाब रहा। अपाचे को jdbc-msql के लिए एक अतिरिक्त कॉन्फ़िगरेशन चरण की आवश्यकता है। सबसे पहले, सुनिश्चित करें कि आपके पास SQL ​​सर्वर के लिए सही अनुदान अनुमतियां सेट हैं।

इसके बाद, उनके समाधान जो से लिया जाता है का पालन करें: http://dev.mysql.com/doc/refman/5.0/en/connector-j-usagenotes-j2ee.html#connector-j-usagenotes-tomcat

पहले, .jar फ़ाइल है कि $ CATALINA_HOME में कनेक्टर/जम्मू/आम/lib के साथ आता है स्थापित इतना है कि यह सभी अनुप्रयोगों में स्थापित करने के लिए उपलब्ध है कंटेनर। आप चल रहे हैं मामले में

<Context ....> 

... 

<Resource name="jdbc/MySQLDB" 
      auth="Container" 
      type="javax.sql.DataSource"/> 

<!-- The name you used above, must match _exactly_ here! 

    The connection pool will be bound into JNDI with the name 
    "java:/comp/env/jdbc/MySQLDB" 
--> 

<ResourceParams name="jdbc/MySQLDB"> 
<parameter> 
    <name>factory</name> 
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> 
</parameter> 

<!-- Don't set this any higher than max_connections on your 
    MySQL server, usually this should be a 10 or a few 10's 
    of connections, not hundreds or thousands --> 

<parameter> 
    <name>maxActive</name> 
    <value>10</value> 
</parameter> 

<!-- You don't want to many idle connections hanging around 
    if you can avoid it, only enough to soak up a spike in 
    the load --> 

<parameter> 
    <name>maxIdle</name> 
    <value>5</value> 
</parameter> 

<!-- Don't use autoReconnect=true, it's going away eventually 
    and it's a crutch for older connection pools that couldn't 
    test connections. You need to decide whether your application 
    is supposed to deal with SQLExceptions (hint, it should), and 
    how much of a performance penalty you're willing to pay 
    to ensure 'freshness' of the connection --> 

<parameter> 
    <name>validationQuery</name> 
    <value>SELECT 1</value> <-- See discussion below for update to this option --> 
</parameter> 

<!-- The most conservative approach is to test connections 
    before they're given to your application. For most applications 
    this is okay, the query used above is very small and takes 
    no real server resources to process, other than the time used 
    to traverse the network. 

    If you have a high-load application you'll need to rely on 
    something else. --> 

<parameter> 
    <name>testOnBorrow</name> 
    <value>true</value> 
</parameter> 

<!-- Otherwise, or in addition to testOnBorrow, you can test 
    while connections are sitting idle --> 

    <parameter> 
    <name>testWhileIdle</name> 
    <value>true</value> 
    </parameter> 

<!-- You have to set this value, otherwise even though 
    you've asked connections to be tested while idle, 
    the idle evicter thread will never run --> 

<parameter> 
    <name>timeBetweenEvictionRunsMillis</name> 
    <value>10000</value> 
</parameter> 

<!-- Don't allow connections to hang out idle too long, 
    never longer than what wait_timeout is set to on the 
    server...A few minutes or even fraction of a minute 
    is sometimes okay here, it depends on your application 
    and how much spikey load it will see --> 

<parameter> 
    <name>minEvictableIdleTimeMillis</name> 
    <value>60000</value> 
</parameter> 

<!-- Username and password used when connecting to MySQL --> 

<parameter> 
<name>username</name> 
<value>someuser</value> 
</parameter> 

<parameter> 
<name>password</name> 
<value>somepass</value> 
</parameter> 

<!-- Class name for the Connector/J driver --> 

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

<!-- The JDBC connection url for connecting to MySQL, notice 
    that if you want to pass any other MySQL-specific parameters 
    you should pass them here in the URL, setting them using the 
    parameter tags above will have no effect, you will also 
    need to use &amp; to separate parameter values as the 
    ampersand is a reserved character in XML --> 

<parameter> 
    <name>url</name> 
    <value>jdbc:mysql://localhost:3306/test</value> 
</parameter> 

0

:

इसके बाद, संदर्भ है कि आपके वेब आवेदन को परिभाषित करता है में $ CATALINA_HOME/conf/server.xml को एक घोषणा संसाधन जोड़कर JNDI डेटा स्रोत कॉन्फ़िगर ग्रहण जावा ईई,
1) के साथ बिलाव को डबल क्लिक करें बिलाव सर्वर
3) सामान्य जानकारी अनुभाग पर, खुले लांच विन्यास क्लिक करें सर्वर टैब
2) पर जाएं।
4) कक्षापथ टैब पर जाएं और जेडीबीसी जार फ़ाइल जोड़ें।
आशा है कि यह काम करता है .. मेरे लिए काम किया।