JDBC connectivty and sql script

  • 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

  • This was removed by the editor as SPAM

  • 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 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply