如何使用 scala.dbc 执行计数命令?

发布于 2024-10-20 20:13:06 字数 873 浏览 1 评论 0原文

我正在尝试连接到 MS/SQL 服务器并执行“计数”语句。我已经到达这里:

import scala.dbc._
import scala.dbc.Syntax._
import scala.dbc.syntax.Statement._
import java.net.URI

object MsSqlVendor extends Vendor {
    val uri = new URI("jdbc:sqlserver://173.248.X.X:Y/DataBaseName")
    val user = "XXX"
    val pass = "XXX"

    val retainedConnections = 5
    val nativeDriverClass = Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); 
    val urlProtocolString = "jdbc:sqlserver:"
}

object Main {
      def main(args: Array[String]) {
      println("Hello, world!")

      val db = new Database(MsSqlVendor)

      val count = db.executeStatement {
        select (count) from (technical)
        }


      println("%d rows counted", count)
      }
}

我收到一条错误消息:“dbc.syntax.Statement.SelectZygote 类型的 scala.dbc.syntax.Statement.select 不接受参数”

如何设置?

I am trying to connect to an MS/SQL server and execute a 'count' statement. I've reached this far:

import scala.dbc._
import scala.dbc.Syntax._
import scala.dbc.syntax.Statement._
import java.net.URI

object MsSqlVendor extends Vendor {
    val uri = new URI("jdbc:sqlserver://173.248.X.X:Y/DataBaseName")
    val user = "XXX"
    val pass = "XXX"

    val retainedConnections = 5
    val nativeDriverClass = Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); 
    val urlProtocolString = "jdbc:sqlserver:"
}

object Main {
      def main(args: Array[String]) {
      println("Hello, world!")

      val db = new Database(MsSqlVendor)

      val count = db.executeStatement {
        select (count) from (technical)
        }


      println("%d rows counted", count)
      }
}

I get an error saying: "scala.dbc.syntax.Statement.select of type dbc.syntax.Statement.SelectZygote does not take parameters"

How do I set this up?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苍景流年 2024-10-27 20:13:06

这可能是一个问题:

val count = db.executeStatement {
        select (count) from (technical)
        }

语句中的 count 引用的是 val count,而不是其他的 count。不过,您还报告了另一个问题。任何地方都没有计数技术定义。也许您在其他地方找到此片段时丢失了它。以下内容确实可以编译,尽管任何人都猜测它是否符合您的要求:

val countx = db.executeStatement {
    select fields "count" from "technical"
}

无论如何,我认为 scala.dbc 早已被弃用。然而,我找不到任何弃用通知,它仍然链接在库 jar 上,甚至在主干上。

This can be a problem:

val count = db.executeStatement {
        select (count) from (technical)
        }

The count inside the statement refers to val count, not to some other count. Still, there's the other problem you report. There's neither a count nor a technical definition anywhere. Maybe it is missing from some other place where you found this snippet. The following does compile, though it's anyone's guess as to whether it does what you want:

val countx = db.executeStatement {
    select fields "count" from "technical"
}

At any rate, I thought scala.dbc was long deprecated. I can't find any deprecation notice, however, and it is still linked on the library jar, even on trunk.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文