I try to run a simple fan script, I hope it's not completely wrong. There
#! /usr/bin/env fan
class Dbtest {
static Void main() {
db := SqlService("mysql",
"jdbc:mysql://localhost:3306/test",
"root",
"boohoo").start
db.open
db.close
}
}
$ ./dbtest.fan
/dbtest.fan(5,15): Unknown method 'dbtest_0::Dbtest.SqlService'
ERROR: cannot compile script
the mysql connector is working, I've tried that with java.
ben
andyThu 12 Feb 2009
Looks like you just need to import sql:
using sql
class Dbtest { ... }
jakbThu 12 Feb 2009
ouch ... thanks andy
unfortunately I still have problems, seems like the mysql connector can't be loaded:
$ ./dbtest.fan
[16:41:43 11-Feb-09] [info] [sql] SqlService started (mysql)
[16:41:43 11-Feb-09] [info] [sql] SqlService connection: jdbc:mysql://localhost:3306/test
WARNING: Cannot preload JDBC driver: com.mysql.jdbc.Driver
sql::SqlErr: No suitable driver found for jdbc:mysql://localhost:3306/test
sql::ConnectionPeer.err (ConnectionPeer.java:297)
$ sed -n 37p /usr/local/fandir/rel/lib/sys.props
sql.mysql.driver=com.mysql.jdbc.Driver
$ echo $CLASSPATH
/usr/lib/jvm/java-6-sun/lib/mysql-connector-java-5.1.7-bin.jar:/usr/lib/jvm/java-6-sun/lib:.
any ideas whats wrong here?
brianFri 13 Feb 2009
The classpath is probably not getting passed into Fan. Stick the connector jar directly into your {java}/lib/ext directory or {fan}/lib/java/ext and see if that fixes it.
andyFri 13 Feb 2009
If I recall correctly, that means your jdbc driver isn't in your classpath. The easiest thing to do is find what VM Fan is using:
C:\dev\fan>fan -version
Fan Launcher
Copyright (c) 2006-2008, Brian Frank and Andy Frank
Licensed under the Academic Free License version 3.0
Java Runtime:
java.vm.name: Java HotSpot(TM) Client VM
java.vm.vendor: Sun Microsystems Inc.
java.vm.version: 11.0-b16
java.home: C:\Program Files\Java\jre6
fan.home: c:\dev\fan
sys.version: 1.0.37
Then actually stick the driver in the JRE lib/ext directory.
jakbFri 13 Feb 2009
ok it works, but only when the driver is in
{fan}/lib/java/ext
brianFri 13 Feb 2009
ok it works, but only when the driver is in
If you look thru bin/fanlaunch I don't think $CLASSPATH is passed to the JVM
jakb Thu 12 Feb 2009
hi
I try to run a simple fan script, I hope it's not completely wrong. There
the mysql connector is working, I've tried that with java.
ben
andy Thu 12 Feb 2009
Looks like you just need to import sql:
jakb Thu 12 Feb 2009
ouch ... thanks andy
unfortunately I still have problems, seems like the mysql connector can't be loaded:
any ideas whats wrong here?
brian Fri 13 Feb 2009
The classpath is probably not getting passed into Fan. Stick the connector jar directly into your {java}/lib/ext directory or {fan}/lib/java/ext and see if that fixes it.
andy Fri 13 Feb 2009
If I recall correctly, that means your jdbc driver isn't in your classpath. The easiest thing to do is find what VM Fan is using:
Then actually stick the driver in the JRE lib/ext directory.
jakb Fri 13 Feb 2009
ok it works, but only when the driver is in
brian Fri 13 Feb 2009
If you look thru bin/fanlaunch I don't think $CLASSPATH is passed to the JVM