+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14

Thread: DatabaseExample issue/question

  1. #1
    Junior Member
    Join Date
    Dec 2007
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DatabaseExample issue/question

    I'm trying to run the DatabaseExample I got from the es-wiki site. I am assuming that I can run it out-of-box once I configure the Extension.xml file to point to my local MySQL instance (and set the two plug-ins as Server Level plug-ins). I'm doing this and I believe it is connecting properly, but I'm having an issue obtaining a connection from the ManagedObjectFactory. Specifically, this line:

    Connection con = (Connection) getApi().acquireManagedObject("ManagedConnectionPo ol", esDB);

    in the DatabasePlugin object is returning a null value. I've checked the name of the ManagedObject specified in this line of code with the name in the Extensions.xml and they match. Is there some other sort of set-up I should be doing?

    As an aside, you have the above line in a try/catch block of code, but the catch only deals with SQLExceptions. At the risk of exposing myself as a buffoon (slightly embarrassing how long I spent on this), you might want to wrap your example code in a generic Exception catch block . . . ;-).

    Let me know, Thanks,
    Joe

  2. #2
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,219
    Thanks
    80
    Thanked 1,087 Times in 1,076 Posts
    Most of the time when I don't get a connection it's because I forgot to start the database going or because my firewall is blocking the port used to connect to the database. You might also need to make sure that you customized the right part of the Extension.xml file (drove me nuts trying to figure out why I couldn't connect to a mySql database - I had customized the Derby values).

    This example was meant as an example rather than a full-blown database utility. That said, it supposed to work "out of the box" if you customize the Extension.xml properly and the DatabasePlugin is a server level component. When I tested this myself, I also had ConnectionPool as a server level component; somebody else posted that this wasn't needed, but you might want to try that.

    Eventually I'll catch up on high priority tasks enough to write a tutorial for the database example, or else turn it into a full database utility that we incorporate into ES4. It's not going to happen this week though.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  3. #3
    Junior Member
    Join Date
    Dec 2007
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Theresa, I assumed it was more example than utility, but I did want to get it running and understand it before I wrote my own. To that effect, I know I don't have firewall or any other type of connection issues -- I am connecting to it right now via a JBOSS instance I'm running concurrently.

    Just to be sure I am editing the right properties in the Extension.xml file, I'm copying it below - could you give it a quick lookover and tell me if I'm off? Also, just to be sure, in order to set the ManagedObject as a server level plug-in, I'll need to make a Plugin entry for it in the Extension.xml file under the Plugins node (along with DatabasePlugin and TestDatabasePlugin below):


    <Extension>
    <Name>DatabaseExample</Name>
    <ManagedObjects>
    <ManagedObject>
    ManagedConnectionPool
    Java
    com.electrotank.electroserver4.examples.database.C onnectionPool</Path>
    <Variables>

    <Variable name="drivers" type="string">com.mysql.jdbc.Driver</Variable>
    <Variable name="logfile" type="string">dbpool.log</Variable>


    <Variable name="pools" type="EsObject">
    <Entry>
    <Variable name="poolname" type="string">mysqlpool</Variable>
    <Variable name="url" type="string">jdbc:mysql://192.168.0.240:3306/SDG</Variable>
    <Variable name="user" type="string">joe</Variable>
    <Variable name="password" type="string">joe</Variable>
    <Variable name="timeout" type="integer">2000</Variable>
    </Entry>
    </Variable>
    </Variables>
    </ManagedObject>
    </ManagedObjects>


    DatabasePlugin
    Java
    com.electrotank.electroserver4.examples.database.D atabasePlugin</Path>
    <Variables>
    <Variable name="poolname" type="string">derbypool</Variable>
    </Variables>
    </Plugin>

    TestDatabasePlugin
    Java
    com.electrotank.electroserver4.examples.database.T estDatabasePlugin</Path>
    </Plugin>
    </Plugins>
    </Extension>

    Thanks,
    Joe

  4. #4
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,219
    Thanks
    80
    Thanked 1,087 Times in 1,076 Posts

    There in the DatabasePlugin variables section you specify that you are using the Derby database, but your only poolname in ConnectionPool is the mySql one. Try changing "derbypool" to "mysqlpool" there near the bottom. I assume that your database is mySql?
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  5. #5
    Junior Member
    Join Date
    Dec 2007
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow, I'm such a doofus. Thanks Theresa!

  6. #6
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,219
    Thanks
    80
    Thanked 1,087 Times in 1,076 Posts
    Hey, I told you that I pulled my hair out trying to debug my own, when I was customizing the wrong section of the managed object - that's pretty much what you did. That's how I spotted it. Been there, done that.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  7. #7
    Junior Member
    Join Date
    Dec 2007
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Lol, fair point. Thanks again!

  8. #8
    Junior Member
    Join Date
    Aug 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    We're having the same problem, using the multipart database example (http://www.es-wiki.com/index.php?tit...tipart_Example), and our dbpool name is correct. Here is our XML:

    Code:
    <Extension>
        <Name>DatabaseExample</Name>
        <ManagedObjects>
            <ManagedObject>
                ManagedConnectionPool
                Java
                com.electrotank.electroserver4.examples.database.ConnectionPool</Path>
                <Variables>
                	
                    <Variable name="drivers" type="string">com.mysql.jdbc.Driver</Variable>
                    <Variable name="logfile" type="string">dbpool.log</Variable>
    				
    				
                    <Variable name="pools" type="EsObject">
                        <Entry>
                            <Variable name="poolname" type="string">mysqlpool</Variable>
                            <Variable name="url" type="string">jdbc:mysql://localhost:3306/netville</Variable>
                            <Variable name="user" type="string">root</Variable>
                            <Variable name="password" type="string">root</Variable>
                            <Variable name="timeout" type="integer">2000</Variable>
    						<Variable name="debug" type="boolean">true</Variable>
                        </Entry>
                    </Variable>
                </Variables>
            </ManagedObject>
        </ManagedObjects>
        
            
                DatabasePlugin
                Java
                com.electrotank.electroserver4.examples.database.DatabasePlugin</Path>
                <Variables>
                     <Variable name="poolname" type="string">mysqlpool</Variable>
                </Variables>
            </Plugin>
            
                QueryDatabasePlugin
                Java
                com.electrotank.electroserver4.examples.database.QueryDatabasePlugin</Path>
            </Plugin>
            
                UpdateDatabasePlugin
                Java
                com.electrotank.electroserver4.examples.database.UpdateDatabasePlugin</Path>
            </Plugin>
            
                InsertDatabasePlugin
                Java
                com.electrotank.electroserver4.examples.database.InsertDatabasePlugin</Path>
            </Plugin>
            
                DeleteDatabasePlugin
                Java
                com.electrotank.electroserver4.examples.database.DeleteDatabasePlugin</Path>
            </Plugin>
        </Plugins>
    </Extension>

  9. #9
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,219
    Thanks
    80
    Thanked 1,087 Times in 1,076 Posts
    The multipart database example was made by Orthiac. Orthiac, can you see what's wrong?

    The version I did still isn't done as a wiki article, and I need to polish it a bit with some tricks that I have learned since I made it. You can find that database example here:
    http://www.es-wiki.com/zips/DatabaseExample.zip
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  10. #10
    Member
    Join Date
    Mar 2008
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    When I had any problems I went straight to the logs. Even when things LOOKED right, the logs would show me different.

    In the post, First things first (DatabaseExample), I listed some of the troubleshooting I had done. The log files were key in determining the problem. If you are not seeing anything in the logs, make sure that 3306 is available to the application. It wouldn't be the first time that there was an unknown port conflict.

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts