<%@ page import="java.util.*" %> <%@ page import="java.sql.*" %> %> <% /* Unlike IIS VBScript, this variable *must* be declared and initialized before calling the Footer.inc include, even if it's supposed to be empty. */ String strPageName = ""; String strQuery = "Select top 20 Company, AssyOrd, LineStation, " + "AssyLine, WhseOrd, WhseOrdPos, Item, QtyRqd From " + "C614.ASCLineStation"; %> MMO Metrics Solution Development - NetCharts Testbed Project - SQL Server Connection Test to the Data Mart

SQL Server Connection Test

Below is a query from the ERP Data Mart Line station orders table for Company 614.
<% Connection objConn = null; String url = "jdbc:microsoft:sqlserver://"; String serverName= "DCACNT53"; String portNumber = "1433"; String databaseName= "ERP_614"; String uName = "userid"; String pwd = "password"; String selectMethod = "direct"; String getConnectionUrl = url + serverName + ":" + portNumber + ";databaseName=" + databaseName + ";selectMethod=" + selectMethod + ";"; try { Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); objConn = java.sql.DriverManager.getConnection(getConnectionUrl,uName,pwd); } catch(Exception e) { e.printStackTrace(); out.println("

Couldn't connect: " + e.getMessage() + ""); } Statement objStmt = objConn.createStatement(); ResultSet objRS = objStmt.executeQuery(strQuery); ResultSetMetaData objRSMeta = objRS.getMetaData(); int intColCount = objRSMeta.getColumnCount(); out.println("

"); for(int i = 1; i <= intColCount; i++) { out.println(""); } out.println(""); while(objRS.next()) { out.println(""); for(int i = 1; i <= intColCount; i++) { out.println(""); } out.println(""); } out.println("
" + objRSMeta.getColumnName(i) + "
" + objRS.getObject(i) + "
"); %> <%@ include file="../Footer.inc" %>