Re: connector mxj can't init db on linux

Andreas Schlicker <[email protected]>
Newsgroups gmane.comp.db.mysql.java
Message-ID <[email protected]>
Hi Eric,

>> I'm using connector mxj 1.1.6 with Java 1.5.0_06 on Debian Linux.
>>
>> I have an small program that fills the database and a second one uses 
>> this db. First, I filled the db and the program exited with the 
>> following output:
>>
>> [MysqldResource] stopping mysqld (process: 28975)
>> 060427 14:43:32 [Note] 
>> /TL/usr1/schlandi/work/master_thesis/GOTaxExplorer/fsst/bin/mysqld: 
>> Normal shutdown
>>
>> 060427 14:43:33  InnoDB: Starting shutdown...
>> 060427 14:43:34  InnoDB: Shutdown completed; log sequence number 0 43634
>> 060427 14:43:34 [Note] 
>> /TL/usr1/schlandi/work/master_thesis/GOTaxExplorer/fsst/bin/mysqld: 
>> Shutdown complete
>>
>> [MysqldResource] clearing options
>> [MysqldResource] shutdown complete
>>
> 
> The output above looks normal and good.

> I understand that it is not practical for you to post your code, but
> perhaps I could persuade you to create some sample code (similar to your
> real code) which also has this problem. Then I could run the code and
> see if I can reproduce the error, and hopefully gain some insight into
> how to fix it.

I attached two files that contain some sample code that reproduces the 
problem on my system.

Regards,
Andreas


-- 
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe:    http://lists.mysql.com/[email protected]
MysqlEmbFill.java (text/x-java, 2.3 KB)
/*
 * MysqlEmbFill.java
 *
 * Created on April 28, 2006, 9:28 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package gotaxexplorer.test;

import com.mysql.management.driverlaunched.ServerLauncherSocketFactory;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;

/**
 *
 * @author schlandi
 */
public class MysqlEmbFill {
    
    /** Creates a new instance of MysqlEmbFill */
    public MysqlEmbFill() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        Connection con = null;
        
        Class.forName(com.mysql.jdbc.Driver.class.getName());
        String url = "jdbc:mysql://localhost:3336/?socketFactory=" + ServerLauncherSocketFactory.class.getName() + "&server.basedir=" +
                System.getProperties().getProperty("user.dir") + "/&server.datadir=" +
                System.getProperties().getProperty("user.dir") + "/data";
        con = DriverManager.getConnection(url, "root", "");
        try {
            Statement stmt = con.createStatement();
            stmt.execute("CREATE DATABASE sim");
            stmt.execute("CREATE TABLE sim.test (id INT NOT NULL PRIMARY KEY, " +
                    "t1 INT NOT NULL, " +
                    "t2 INT NOT NULL, " +
                    "s DOUBLE NOT NULL)");
            
            con.setAutoCommit(false);
            
            PreparedStatement pstmt = con.prepareStatement("INSERT INTO sim.test(id, t1, t2, s) VALUES (?, ?, ?, ?)");
            for (int i = 1; i < 100; ++i) {
                pstmt.setInt(1, i);
                pstmt.setInt(2, i*2);
                pstmt.setInt(3, i*3);
                pstmt.setDouble(4, i*1.4);
                pstmt.addBatch();
            }
            pstmt.executeBatch();
            con.commit();
            stmt.execute("CREATE INDEX term1_id ON sim.test (t1, t2)");
            stmt.execute("ANALYZE TABLE sim.test");
            
            con.setAutoCommit(true);
            
            stmt.close();
            pstmt.close();
            con.close();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            ServerLauncherSocketFactory.shutdown("localhost:3336");
        }
    }
    
}
MysqlEmbRet.java (text/x-java, 1.6 KB)
/*
 * MysqlEmbRet.java
 *
 * Created on April 28, 2006, 9:29 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package gotaxexplorer.test;

import com.mysql.management.driverlaunched.ServerLauncherSocketFactory;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author schlandi
 */
public class MysqlEmbRet {
    
    /** Creates a new instance of MysqlEmbRet */
    public MysqlEmbRet() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        Connection con = null;
        try {
        Class.forName(com.mysql.jdbc.Driver.class.getName());
        String url = "jdbc:mysql://localhost:3336/sim?socketFactory=" + ServerLauncherSocketFactory.class.getName() + "&server.basedir=" +
                System.getProperties().getProperty("user.dir") + "/&server.datadir=" +
                System.getProperties().getProperty("user.dir") + "/data";
        con = DriverManager.getConnection(url, "root", "");
        
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT * FROM sim.test");
        while (rs.next())
            System.out.println(rs.getInt(1) + " " + rs.getInt(2) + " " + rs.getInt(3) + " " + rs.getDouble(4));
        
        rs.close();
        stmt.close();
        con.close();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            ServerLauncherSocketFactory.shutdown("localhost:3336");
        }
    }
    
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.