Help: tomcat and JDBC/ODBC

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Riccardo

    Help: tomcat and JDBC/ODBC

    Hi,

    This jsp code doesn't run. Why ?

    -----------------------------------------------------------
    <%@ page import="java.sq l.*" %>

    <%!
    String Query(String SQL, String DSN)
    {
    ResultSet rs;
    Statement stmt;
    String App = "";
    try
    {
    Class.forName(" sun.jdbc.odbc.J dbcOdbcDriver") ;
    Connection conn = DriverManager.g etConnection("j dbc:odbc:"+"DNS ");
    stmt = conn.createStat ement();
    //......
    stmt.close();
    return App;
    }
    catch (Exception e)
    {
    return e.toString();
    }
    }
    %>

    <HTML>
    <BODY>
    <%= Query("select * from table","DNS") %>
    </BODY>
    </HTML>

    -------------------------------------------------------------------

    Tomcat show me this error:

    java.sql.SQLExc eption: [Microsoft][ODBC Driver Manager] Data source
    name not found and no default driver specified

    Can I resolve this problem in tomcat ?

    I use Tomcat 5.5 and jdk1.5.0_01.
    The pure java code is ok and i can connect to the database.

    Thanks in advance.

    Rik
  • Edwin Martin

    #2
    Re: Help: tomcat and JDBC/ODBC

    Riccardo wrote:
    [color=blue]
    > This jsp code doesn't run. Why ?[/color]
    [color=blue]
    > String Query(String SQL, String DSN)
    > Connection conn = DriverManager.g etConnection("j dbc:odbc:"+"DNS ");[/color]

    DSN or DNS?

    Edwin Martin.

    --

    Comment

    • Jubril OyeSiji

      #3
      Re: tomcat and JDBC/ODBC

      I think there is a problem with your
      Connection conn = DriverManager.g etConnection("j dbc:odbc:"+"DNS ");
      Statement Once you have defined your odbc setting by going to the ODBC
      Managerr in windows you only need the name as in

      String url = "jdbc:odbc:<odb c Name>";
      Connection con = DriverManager.g etConnection(ur l, "name", "password") ;



      Jubril

      "Riccardo" <rkpisanu@yahoo .it> wrote in message
      news:c421a832.0 503170950.241dc 6d4@posting.goo gle.com...[color=blue]
      > Hi,
      >
      > This jsp code doesn't run. Why ?
      >
      > -----------------------------------------------------------
      > <%@ page import="java.sq l.*" %>
      >
      > <%!
      > String Query(String SQL, String DSN)
      > {
      > ResultSet rs;
      > Statement stmt;
      > String App = "";
      > try
      > {
      > Class.forName(" sun.jdbc.odbc.J dbcOdbcDriver") ;
      > Connection conn = DriverManager.g etConnection("j dbc:odbc:"+"DNS ");
      > stmt = conn.createStat ement();
      > //......
      > stmt.close();
      > return App;
      > }
      > catch (Exception e)
      > {
      > return e.toString();
      > }
      > }
      > %>
      >
      > <HTML>
      > <BODY>
      > <%= Query("select * from table","DNS") %>
      > </BODY>
      > </HTML>
      >
      > -------------------------------------------------------------------
      >
      > Tomcat show me this error:
      >
      > java.sql.SQLExc eption: [Microsoft][ODBC Driver Manager] Data source
      > name not found and no default driver specified
      >
      > Can I resolve this problem in tomcat ?
      >
      > I use Tomcat 5.5 and jdk1.5.0_01.
      > The pure java code is ok and i can connect to the database.
      >
      > Thanks in advance.
      >
      > Rik[/color]


      Comment

      • Riccardo

        #4
        Re: Help: tomcat and JDBC/ODBC

        Edwin Martin <e.j.martin@che llo.nl> wrote in message news:<2Ij_d.105 935$o9.230@amsn ews03-serv.chello.com >...[color=blue]
        > Riccardo wrote:
        >[color=green]
        > > This jsp code doesn't run. Why ?[/color]
        >[color=green]
        > > String Query(String SQL, String DSN)
        > > Connection conn = DriverManager.g etConnection("j dbc:odbc:"+"DNS ");[/color]
        >
        > DSN or DNS?
        >
        > Edwin Martin.[/color]

        DSN.

        Bye Bye

        Comment

        • Riccardo

          #5
          Re: tomcat and JDBC/ODBC

          Many thank for the reply.
          The problem is not url, because it run on java class but not with jsp.
          Probably the problem is a tomcat configuration or bug.

          Bye.

          Rik

          "Jubril OyeSiji" <oyesiji@hotmai l.com> wrote in message news:<%jl_d.381 8$uw6.2640@trnd dc06>...[color=blue]
          > I think there is a problem with your
          > Connection conn = DriverManager.g etConnection("j dbc:odbc:"+"DNS ");
          > Statement Once you have defined your odbc setting by going to the ODBC
          > Managerr in windows you only need the name as in
          >
          > String url = "jdbc:odbc:<odb c Name>";
          > Connection con = DriverManager.g etConnection(ur l, "name", "password") ;
          >
          >
          >
          > Jubril
          >
          > "Riccardo" <rkpisanu@yahoo .it> wrote in message
          > news:c421a832.0 503170950.241dc 6d4@posting.goo gle.com...[color=green]
          > > Hi,
          > >
          > > This jsp code doesn't run. Why ?
          > >
          > > -----------------------------------------------------------
          > > <%@ page import="java.sq l.*" %>
          > >
          > > <%!
          > > String Query(String SQL, String DSN)
          > > {
          > > ResultSet rs;
          > > Statement stmt;
          > > String App = "";
          > > try
          > > {
          > > Class.forName(" sun.jdbc.odbc.J dbcOdbcDriver") ;
          > > Connection conn = DriverManager.g etConnection("j dbc:odbc:"+"DNS ");
          > > stmt = conn.createStat ement();
          > > //......
          > > stmt.close();
          > > return App;
          > > }
          > > catch (Exception e)
          > > {
          > > return e.toString();
          > > }
          > > }
          > > %>
          > >
          > > <HTML>
          > > <BODY>
          > > <%= Query("select * from table","DNS") %>
          > > </BODY>
          > > </HTML>
          > >
          > > -------------------------------------------------------------------
          > >
          > > Tomcat show me this error:
          > >
          > > java.sql.SQLExc eption: [Microsoft][ODBC Driver Manager] Data source
          > > name not found and no default driver specified
          > >
          > > Can I resolve this problem in tomcat ?
          > >
          > > I use Tomcat 5.5 and jdk1.5.0_01.
          > > The pure java code is ok and i can connect to the database.
          > >
          > > Thanks in advance.
          > >
          > > Rik[/color][/color]

          Comment

          Working...