- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Introduction and a question
Mon, 2009-03-23, 22:46
Hello all,
After enough podcasts, Scala concepts are finally starting to click in my thoughts and NetBeans is running great (not so great with Eclipse plugin). I've made lots of progress, having just started using the language last week, but one error is complicating my learning.
I have this JDBC sample running: http://scala.sygneca.com/code/simplifying-jdbc
Except, this line:
implicit def str2RichPrepared(s: String)(implicit conn: Connection): RichPreparedStatement = conn prepareStatement(s);
and this usage:
for (val person3 <- "select * from person" <<! (rs => Person(rs,rs,rs)))
println(person3.toXML);
are giving me:
found : java.sql.PreparedStatement
required: RichSQL.RichPreparedStatement
Note: implicit method rich2St is not applicable here
because it comes after the application point and it lacks an explicit result type
implicit def str2RichPrepared(s: String)(implicit conn: Connection): RichPreparedStatement = conn prepareStatement(s);
Does anyone have any analysis to offer, please?
Steve Sobczak
After enough podcasts, Scala concepts are finally starting to click in my thoughts and NetBeans is running great (not so great with Eclipse plugin). I've made lots of progress, having just started using the language last week, but one error is complicating my learning.
I have this JDBC sample running: http://scala.sygneca.com/code/simplifying-jdbc
Except, this line:
implicit def str2RichPrepared(s: String)(implicit conn: Connection): RichPreparedStatement = conn prepareStatement(s);
and this usage:
for (val person3 <- "select * from person" <<! (rs => Person(rs,rs,rs)))
println(person3.toXML);
are giving me:
found : java.sql.PreparedStatement
required: RichSQL.RichPreparedStatement
Note: implicit method rich2St is not applicable here
because it comes after the application point and it lacks an explicit result type
implicit def str2RichPrepared(s: String)(implicit conn: Connection): RichPreparedStatement = conn prepareStatement(s);
Does anyone have any analysis to offer, please?
Steve Sobczak
2009/3/23 Steve Sobczak :
> Hello all,
>
> After enough podcasts, Scala concepts are finally starting to click in my
> thoughts and NetBeans is running great (not so great with Eclipse plugin).
> I've made lots of progress, having just started using the language last
> week, but one error is complicating my learning.
>
> I have this JDBC sample running:
> http://scala.sygneca.com/code/simplifying-jdbc
>
> Except, this line:
> implicit def str2RichPrepared(s: String)(implicit conn: Connection):
> RichPreparedStatement = conn prepareStatement(s);
>
> and this usage:
> for (val person3 <- "select * from person" < Person(rs,rs,rs)))
> println(person3.toXML);
>
> are giving me:
> found : java.sql.PreparedStatement
> required: RichSQL.RichPreparedStatement
> Note: implicit method rich2St is not applicable here
> because it comes after the application point and it lacks an explicit result
> type
> implicit def str2RichPrepared(s: String)(implicit conn: Connection):
> RichPreparedStatement = conn prepareStatement(s);
>
> Does anyone have any analysis to offer, please?
Well, it might help you to note that the implicit method rich2St is
not applicable here because it comes after the application point and
it lacks an explicit result type.
So, in order to fix the problem, you could give it an explicit result
type or put it before the application point.