首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Java JDBC Sybase JConnect

Java JDBC Sybase JConnect
EN

Stack Overflow用户
提问于 2012-02-02 14:23:04
回答 1查看 3.1K关注 0票数 1

我需要在我的Java应用程序中使用sybase的JConnect(jConn3.jar)驱动程序连接到我的SQL Anywhere 11 (Sybase)数据库。我已经尝试了文档并联系了技术支持,但没有得到有效的帮助:(。另外,如果有人知道如何使用此驱动程序连接到Crystal Reports XI,将不胜感激……

EN

回答 1

Stack Overflow用户

发布于 2012-02-02 15:00:46

确保jconn3.jar位于应用程序的类路径中。然后使用jdbc驱动程序,如下所示:

代码语言:javascript
复制
   try {
       Class.forName("com.mysql.jdbc.Driver").newInstance();
       String url = "jdbc:mysql://localhost/coffeebreak";
       conn = DriverManager.getConnection(url, "username", "password");

       // Do your stuff

       conn.close();
   } catch (Exception ex) {
   ...
   }

你对我的回答的评论很有帮助。我们也遇到过这样的问题。我们的项目在JSP中使用了查看器。深入查看我们的报告时出现问题。第一次打开报表时,查看器会为报表生成一个标识符。您必须将其存储在会话中,以便在向下钻取时,可以使用此标识符。这样,您就表明它仍然是相同的报表,并且查看器将使用相同的数据源。下面是一段代码,它应该比文本更清晰:

代码语言:javascript
复制
// Report viewer
CrystalReportViewer crystalViewer = new CrystalReportViewer();

// Key to store the report source
String reportSourceSessionKey = "anyKeyYouWant";
Object reportSource = null;

// Get the report name passed in parameter
String reportName = request.getParameter("report");
if (reportName != null) {
    // Build your report
    ReportClientDocument reportClientDoc = new ReportClientDocument();

    // ...

    // Store de report source
    reportSource = reportClientDoc.getReportSource();
    session.setAttribute(reportSourceSessionKey, reportSource);

    // Close the report document
    reportClientDoc.close();
} else {
    reportSource = session.getAttribute(reportSourceSessionKey);
}

// Set the source of the viewer
crystalViewer.setReportSource(reportSource);

....

这解决了我们的JNDI问题。希望它能帮到你。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9108007

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档