Quote (bizzy1999 @ Nov 17 2015 08:46pm)
I read them, still don't understand how they are wrong.
New code with no problems still getting an exception thrown:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page
language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="java.sql.*"%>
<html>
<head>
<title>Connect to Northwind_64 Bit SQL Server DSN</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<%
//setup url (bridge-driver name + ODBC DSN), user, and password Strings
String dsn = "Northwind_64";
String dbUrl = "jdbc:odbc:" + dsn;
String user = "";
String password = "";
Connection connection = null;
// try to load the JDBC-ODBC driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
out.print("About to try to connect to ODBC DSN: " + dbUrl + "<br /><br />");
//try to connect to database using the above Strings
connection = DriverManager.getConnection(dbUrl, user, password);
out.print("Connected to ODBC DSN: " + dbUrl + "<br /><br />");
Statement stmt;
System.out.println("Creating statement...");
stmt = connection.createStatement();
String sql;
sql = "SELECT ProductID, ProductName, UnitPrice FROM Northwind.dbo.Products";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()){
int id = rs.getInt("UnitPrice");
int is = rs.getInt("ProductID");
String last = rs.getString("ProductName");
// Display values;
System.out.print("ProductID: " + id);
System.out.print(", UnitePrice: " + is);
System.out.print(", ProductName: " + last);
}
%>
</body>
</html>
Exception thrown by application class 'sun.jdbc.odbc.JdbcOdbc.createSQLException:6976'
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6976)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7133)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataInteger(JdbcOdbc.java:3830)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataInteger(JdbcOdbcResultSet.java:5649)
at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(JdbcOdbcResultSet.java:594)
at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(JdbcOdbcResultSet.java:612)
at com.ibm._jsp._Product._jspService(_Product.java:129)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:101)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1240)
at [internal classes]
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:215)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1033)
at [internal classes]
This post was edited by bizzy1999 on Nov 17 2015 06:03pm