不指定数据库的JDBC MYSQL连接?

编程入门 行业动态 更新时间:2024-10-27 15:25:32
本文介绍了不指定数据库的JDBC MYSQL连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用SphinxQL MySQL客户端,该客户端将索引存储为表",但没有真正的数据库"概念...一个指定了sphinx mysql实例在理论上侦听的端口(在我的情况下为9306)应该能够正常通信.

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.

我有以下测试代码:

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?

推荐答案

适用于1.10-beta www.olegsmith/2010/12/scalalift-sphinxql.html 不适用于2.0.1-beta.使用mysql-connector-java 5.1.15.

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

更多推荐

不指定数据库的JDBC MYSQL连接?

本文发布于:2023-10-17 11:11:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1500720.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   JDBC   MYSQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!