April 29, 2003 at 2:32 pm
Hello,
I am trying to get connected to SQL server running on a w2k from HP-UX 64 bit using JDBC and run a select query and capture the result to a flat file..
Is their any sample program that I can refer to and the information..
I am not able to run a query,but am able to get connected to SQL server using JDBC...
Any help
May 21, 2003 at 3:04 am
Hi,
here is a snippet of a jsp page I built just for fun to test java?!? and SQL Server.
www_assetlist is a view on the SQL Server.
<%
String lpszSQL;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (ClassNotFoundException e)
{
out.println("<h1>Driver not found:" + e + e.getMessage() + "</h1>" );
}
try
{
Connection conn = DriverManager.getConnection ("jdbc:odbc:sqlprost");
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs;
if (request.getParameter("Assets")==null)
{
lpszSQL = "www_assetlist '%'";
}
else
{
lpszSQL = "www_assetlist '"+request.getParameter("Assets")+"'";
}
rs = stmt.executeQuery(lpszSQL);
%>
<table>
<tr>
<td>
<font class = "frank">
<b>
Ka-Nr
</b>
</font>
</td>
<td>
<font class="frank">
<b>
WKN
</b>
</font>
</td>
<td>
<font class="frank">
<b>
Bezeichnung
</b>
</font>
</td>
<td>
<font class="frank">
<b>
Klasse
</b>
</font>
</td>
</tr>
<%
while ( rs.next() )
{
String kanr = rs.getString("Ka-Nr");
String wkn = rs.getString("WKN");
String bez = rs.getString("Kapitalanlagenbezeichnung");
String klasse = rs.getString("Risikoklasse");
%>
<tr>
<td>
<font class="frank">
<%
out.println(kanr);
%>
</font>
</td>
<td>
<font class="frank">
<%
out.println(wkn);
%>
</font>
</td>
<td>
<font class="frank">
<%
out.println(bez);
%>
</font>
</td>
<td>
<font class="frank">
<%
out.println(klasse);
%>
</font>
</td>
</tr>
<%
}
out.println( "</table>" );
conn.close();
} catch (Exception e)
{
out.println( "<h1>exception: "+e+e.getMessage()+"</h1>" );
}
%>
It works just fine.
Maybe it helps?
Cheers,
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy