Thanks,
Mark
On Wednesday, August 04, 2010 01:42:16 pm marcuskaz wrote:
> I have a Scala program which I pass a parameter, the program connects
> to the database, performs a query based on the parameter and then
> closes the database connection. It is doing so using standard JDBC and
> the mysql connector.
>
> When using the sbt shell, the first time I run the program it works
> fine. The second time I run it, in the same shell, it gives the
> following JDBC error:
> error.java.sql.SQLException: No suitable driver found for
> jdbc:mysql...
>
>
> If I run from my terminal (not the sbt shell) I can run multiple
> times, but each of these is probably a new instance. However, I can
> not pass in parameters using
> $ sbt run "params"
>
>
> Below is a simple case which duplicates it for me:
>
> object DemoBug {
>
> def main(args: Array[String]) {
> import java.sql._
> // val param = args(0)
> classOf[com.mysql.jdbc.Driver]
> val conn = DriverManager.getConnection("jdbc:mysql://localhost:
> 3306/nfldata","root","n3wb4by")
> val statement = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
> ResultSet.CONCUR_READ_ONLY)
>
> val sql = " SELECT 'foo' as bar"
> val rs = statement.executeQuery(sql)
> while (rs.next) {
> println(rs.getString("bar"))
> }
> conn.close
> }
>
> }