我需要在我的Java应用程序中使用sybase的JConnect(jConn3.jar)驱动程序连接到我的SQL Anywhere 11 (Sybase)数据库。我已经尝试了文档并联系了技术支持,但没有得到有效的帮助:(。另外,如果有人知道如何使用此驱动程序连接到Crystal Reports XI,将不胜感激……
发布于 2012-02-02 15:00:46
确保jconn3.jar位于应用程序的类路径中。然后使用jdbc驱动程序,如下所示:
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中使用了查看器。深入查看我们的报告时出现问题。第一次打开报表时,查看器会为报表生成一个标识符。您必须将其存储在会话中,以便在向下钻取时,可以使用此标识符。这样,您就表明它仍然是相同的报表,并且查看器将使用相同的数据源。下面是一段代码,它应该比文本更清晰:
// 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问题。希望它能帮到你。
https://stackoverflow.com/questions/9108007
复制相似问题