Re: [sbt] Running multiple times in same shell causes JDBC error

94 views
Skip to first unread message
Message has been deleted

Mark Harrah

unread,
Aug 5, 2010, 11:04:24 AM8/5/10
to simple-b...@googlegroups.com
As mentioned in the comment on the bug report, please provide a complete,
self-contained project that demonstrates the issue. Code is only one part of
that.

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
> }
>
> }

Reply all
Reply to author
Forward
0 new messages