Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

JDBC MYSQL Connection without specifying database?

0

44 views

I am using the SphinxQL MySQL client which stores indexes as "tables" but has no real notion of a "database"...One specifies the port (9306 in my case) at which the sphinx mysql instance listens and in theory should be able to communicate as normal.

I have the following test code:

     import java.sql.*;

        public class Dbtest{


                public static void main (String[]args){


                        try{

                   Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:9306",
 "user","password");
    con.setReadOnly(true);
       Statement stmt = con.createStatement();

     ResultSet res = stmt.executeQuery("SELECT * from index_turned_table");

       while (res.next()){
        String stuff1 = res.getString(1);
        String stuff2 = res.getString(2);
        System.out.println("Adding " + stuff1);
        System.out.println("Adding " + stuff2);

                    }


            res.close();
            stmt.close();
           con.close();
                        }
             catch(Exception e)
                 {
             System.out.println (e);
                  }

                }
        }

Upon execution, the code just hangs and does nothing and doesn't print out an exception. What are useful things I can do to figure this out or if any one has direct experience what might be going on?

asked June 16, 2011 7:17 am CDT
posted via StackOverflow

2 Answers

1
Best answer
 

This work with 1.10-beta http://www.olegsmith.com/2010/12/scalalift-sphinxql.html and not work with 2.0.1-beta. Use mysql-connector-java 5.1.15.

answered June 22, 2011 11:32 am CDT
0
 

Your SphinxQL instance is listening on port 9306. Your MySQL is listening on some other port, likely on the default 3306. You can use MySQL JDBC driver to connect to MySQL, but you cannot use it to connect to SphinxQL. It just doesn't understand JDBC driver communication protocol.

answered June 22, 2011 11:32 am CDT

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
JDBC SQL Connection
March 1, 2011