+ Reply to Thread
Results 1 to 6 of 6

Thread: mysq in ubuntu linux

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mysq in ubuntu linux

    how to use mysql database in ubuntu? i tried using code example in "DatabaseWithJDBC" , but it failed, it the error occurred in

    Code:
    con = (Connection) getApi().acquireManagedObject("conPol", esDB);
    this is my extension.xml for some reference
    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <Extension>
        <Name>maxi_ext</Name>
        <ManagedObjects>
            <ManagedObject>
                <Handle>conPol</Handle>
                <Type>Java</Type>
                <Path>max.ext.conPol</Path>
                <Variables>
                    <Variable name="drivers" type="string">com.mysql.jdbc.Driver</Variable>
                    <Variable name="pools" type="EsObject">
                        <Entry>
                            <Variable name="poolname" type="string">mysqlpool</Variable>
                            <Variable name="url" type="string">jdbc:mysql://localhost:3306/MySQL</Variable>
                            <Variable name="user" type="string">korban</Variable>
                            <Variable name="password" type="string">sambal</Variable>
                            <Variable name="timeout" type="integer">2000</Variable>
                        </Entry>
                    </Variable>
                </Variables>
            </ManagedObject>
        </ManagedObjects>
        <EventHandlers>
           	<LoginHandlers>
        	        <LoginHandler>
        	            <Handle>login</Handle>
        	            <Type>Java</Type>
        	            <Path>max.ext.login</Path>
        	            <Variables>
    		    	<Variable name="poolname" type="string">mysqlpool</Variable>
                	    </Variables>	
        	        </LoginHandler>
        	</LoginHandlers>
        </EventHandlers>
    </Extension>
    Last edited by tcarr; 11-13-2010 at 02:34 AM. Reason: problem fixed so changed the prefix

  2. #2
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,209
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    What is the exact error message that you see in the log? The first thing I would look at is this line:
    jdbc:mysql://localhost:3306/MySQLDatabase

    Try using this and see if that connects to something:
    jdbc:mysql://localhost:3306

    I'm much more familiar with the JDBI example than the JDBC one (even if I wrote both, the JDBI version is the pattern I've used more often), and in my opinion that one is a lot easier to set up and maintain.

    See this Java tutorial for more info (and examples) on connecting to a database.

    You also have to configure the MySQL database to allow for connection (port 3306 is the default port) or it will refuse all connections.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  3. #3
    Junior Member
    Join Date
    Sep 2010
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the error message that i only got is java.lang.RuntimeException: java.sql.SQLException, then i add ((SQLException)e).getSQLState() , ((SQLException)e).getErrorCode() , and ((SQLException)e).getMessage() i got, null, 0, and null...

  4. #4
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,209
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    What is the name of the MySQL database that you are trying to access, inside your local MySQL? I assume that you have the username and password correct.
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

  5. #5
    Junior Member
    Join Date
    Sep 2010
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it works after i change jdbc:mysql://localhost:3306/MySQL into jdbc:mysql://10.0.0.201:3306 mybe because of bind-address in /etc/mysql/my.cnf , thanks for the help

  6. #6
    Administrator tcarr's Avatar
    Join Date
    Dec 2007
    Posts
    7,209
    Thanks
    80
    Thanked 1,086 Times in 1,075 Posts
    Hooray! So glad you have it working now!
    Teresa Carrigan
    Senior Engineer
    Electrotank, Inc.

+ 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