Monday, March 19, 2012

From MySQL to MSSQL

Hi, all,
I have a simple jsp page which conneced to mysql database with no problem, but
after I changed to production database server, MSSQL, I got nothing returned,
nothing displayed on web browser. I did changed jdbc drive, etc., please help.
Thanks in advance.
For example:
in MySQL:
20040301 010203
in MSSQL
<%@. page contentType="text/html; charset=UTF-8" language="java"%>
<%@. page import="java.sql.*" %>
<%
String connectionURL =
"jdbc:microsoft:sqlserver://DBServer:1433/Tracking;User=user;Password=pw";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
String sSQLString="SELECT * FROM Tracking";
%>
<html>
<head>
<title>
Report
</title>
</head>
<body bgcolor="#ffffc0">
<hr>
<table width="100%" border="1">
<% try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLSer verDriver").newInstance();
connection = DriverManager.getConnection(connectionURL);
statement = connection.createStatement();
rs = statement.executeQuery(sSQLString);
while (rs.next()) { %>
<tr>
<td><tt><% out.print("FromDate"); %></tt></td>
<td><tt><% out.print("FromTime"); %></td>
</tr>
<% }
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (rs != null) rs.close();
if (statement != null) statement.close();
if (connection != null) connection.close();
} %>
</table>
</body>
</html>
Check your connection string. You are specifying the server name and port
number, but is Tracking supposed to be a named instance or your database
name? If it is supposed to be a named instance, then you need to use
something like the following:
String connectionURL =
"jdbc:microsoft:sqlserver://DBServer\\Tracking;User=user;Password=pw";
or
String connectionURL =
"jdbc:microsoft:sqlserver://DBServer:xxxx;User=user;Password=pw";
where "xxxx" is the port of the Tracking instance. If Tracking is supposed
to be your database name, then you need to specify "DatabaseName=Tracking;"
somewhere in your connection string.
Carb Simien, MCSE MCDBA MCAD
Microsoft Developer Support - Web Data
Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
Are you secure? For information about the Strategic Technology Protection
Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.
| NNTP-Posting-Date: Tue, 30 Mar 2004 23:19:43 -0600
| From: Jason <jhsu8999@.yahoo.com>
| Newsgroups: microsoft.public.sqlserver.jdbcdriver
| Subject: From MySQL to MSSQL
| Date: Tue, 30 Mar 2004 22:21:36 -0700
| Message-ID: <o7lk60loka08go7pm9al9utlqv8nlmb8nb@.4ax.com>
| X-Newsreader: Forte Agent 2.0/32.640
| MIME-Version: 1.0
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| Lines: 63
| NNTP-Posting-Host: 67.161.247.249
| X-Trace:
sv3-6XJo0FwryFfK+LFOSREhLrCcGZ+gMm/b2KdpOiD28o2vJX0FScRdwjqwqv9Brbe8pNEmK9fe
wv5hG1t!8LtCcuWLwevoq0HwtKMPyWl0BjtkH9ET1C4yeP4WyG jJdEdXfEAQgaTlk2TtdUmMBJYn
/iIOTA==
| X-Complaints-To: abuse@.comcast.net
| X-DMCA-Complaints-To: dmca@.comcast.net
| X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
| X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properly
| X-Postfilter: 1.1
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwix.com!newsfeed.cwix.co
m!border1.nntp.ash.giganews.com!border2.nntp.sjc.g iganews.com!border1.nntp.s
jc.giganews.com!nntp.giganews.com!local1.nntp.sjc. giganews.com!nntp.comcast.
com!news.comcast.com.POSTED!not-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.sqlserver.jdbcdriver:5821
| X-Tomcat-NG: microsoft.public.sqlserver.jdbcdriver
|
| Hi, all,
| I have a simple jsp page which conneced to mysql database with no
problem, but
| after I changed to production database server, MSSQL, I got nothing
returned,
| nothing displayed on web browser. I did changed jdbc drive, etc., please
help.
| Thanks in advance.
|
| For example:
| in MySQL:
| --
| 20040301 010203
|
| in MSSQL
| --
|
|
| <%@. page contentType="text/html; charset=UTF-8" language="java"%>
| <%@. page import="java.sql.*" %>
|
| <%
| String connectionURL =
| "jdbc:microsoft:sqlserver://DBServer:1433/Tracking;User=user;Password=pw";
| Connection connection = null;
| Statement statement = null;
| ResultSet rs = null;
|
| String sSQLString="SELECT * FROM Tracking";
| %>
|
| <html>
| <head>
| <title>
| Report
| </title>
| </head>
| <body bgcolor="#ffffc0">
| <hr>
|
| <table width="100%" border="1">
| <% try {
|
|
Class.forName("com.microsoft.jdbc.sqlserver.SQLSer verDriver").newInstance();
|
| connection = DriverManager.getConnection(connectionURL);
| statement = connection.createStatement();
| rs = statement.executeQuery(sSQLString);
|
| while (rs.next()) { %>
| <tr>
| <td><tt><% out.print("FromDate"); %></tt></td>
| <td><tt><% out.print("FromTime"); %></td>
| </tr>
| <% }
| } catch (Exception ex) {
| ex.printStackTrace();
| } finally {
| if (rs != null) rs.close();
| if (statement != null) statement.close();
| if (connection != null) connection.close();
| } %>
| </table>
| </body>
| </html>
|
|

No comments:

Post a Comment