Hey guys, I’m trying to get JRuby to talk to mysql. Can’t beleive how
much of a pain in the butt this is! After searching the web I’m
beginning to believe this is a right of passage!
Satish’s blog post here:
has helped…but I’m getting an SQLException. Maybe its how I’m setting
the password?
Anyway heres my code…if someone could eyeball it and tell me where I’m
screwing up I’d appreciated it. Thanx in advance…
On Wed, 2011-02-16 at 18:39 +0100, Mark Locklear wrote:
screwing up I’d appreciated it. Thanx in advance…
end
rescue JavaLang::ClassNotFoundException
puts “ClassNotFoundException”
rescue JavaSql::SQLException
puts “SQLException”
end
–
Nick G.
Developer @ Media Service Provider
+44 207 729 4797
The last packet sent successfully to the server was 0 milliseconds ago.
The driver has not received any packets from the server.
from sun/reflect/NativeConstructorAccessorImpl.java:57:in newInstance' from sun/reflect/DelegatingConstructorAccessorImpl.java:45:innewInstance’
from java/lang/reflect/Constructor.java:532:in newInstance' from com/mysql/jdbc/Util.java:409:inhandleNewInstance’
from com/mysql/jdbc/SQLError.java:1118:in createCommunicationsException' from com/mysql/jdbc/MysqlIO.java:343:in’
from com/mysql/jdbc/ConnectionImpl.java:2308:in connectOneTryOnly' from com/mysql/jdbc/ConnectionImpl.java:2122:increateNewIO’
from com/mysql/jdbc/ConnectionImpl.java:774:in <init>' from com/mysql/jdbc/JDBC4Connection.java:49:in’
from sun/reflect/NativeConstructorAccessorImpl.java:-2:in newInstance0' from sun/reflect/NativeConstructorAccessorImpl.java:57:innewInstance’
from sun/reflect/DelegatingConstructorAccessorImpl.java:45:in newInstance' from java/lang/reflect/Constructor.java:532:innewInstance’
from com/mysql/jdbc/Util.java:409:in handleNewInstance' from com/mysql/jdbc/ConnectionImpl.java:375:ingetInstance’
from com/mysql/jdbc/NonRegisteringDriver.java:289:in connect' from java/sql/DriverManager.java:620:ingetConnection’
from java/sql/DriverManager.java:200:in getConnection' from mysql2.rb:13:infile’
module JavaLang
include_package “java.lang”
end
module JavaSql
include_package ‘java.sql’
end
begin
com.mysql.jdbc.Driver.new
conn =
JavaSql::DriverManager.getConnection(“jdbc:mysql://127.0.0.1:3306/clist”,
“root”, “wintas”);
stmt = conn.createStatement
rs = stmt.executeQuery(“select * from post”)
while (rs.next) do
puts rs.getString(“post_location”)
end
rs.close
stmt.close
conn.close()
rescue JavaLang::ClassNotFoundException
puts “ClassNotFoundException”
end
I don’t think port numbers go up to 327280 (take a look at Service Name and Transport Protocol Port Number Registry). If that was a typo, check
that you can connect to the host and port that you are using with
something like telnet.
On Wed, 2011-02-16 at 18:48 +0100, Mark Locklear wrote:
newInstance' from sun/reflect/DelegatingConstructorAccessorImpl.java:45:in newInstance’
–
Nick G.
Developer @ Media Service Provider
+44 207 729 4797