Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

JSP and Sybase Connection

  • 25-03-2003 11:27am
    #1
    Registered Users, Registered Users 2 Posts: 822 ✭✭✭


    Hey guys and girls, I just have a quick question for you all:

    I've tried using classes and Now Im trying to just implement my JSP Site in jsp only. Here is my connection code:

    [PHP]
    <HTML>
    <HEAD><TITLE> Listing the Content of a Database</TITLE></HEAD>
    <BODY>
    <P> Content of the Product database:
    <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0>
    <TR><TD> Product Name </TD>
    <TD> Class </TD>
    <TD> Sub Class </TD>
    </TR>

    <% String strDBUser = "*****";
    String strDBPwd = "******";

    Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
    //java.sql.Connection connection = java.sql.DriverManager.getConnection(strDBUrl, props);
    java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:sybase:Tds:BLAH:5000/BLAH");
    java.sql.Statement statement = connection.createStatement();
    java.sql.ResultSet columns = statement.executeQuery("SELECT * FROM euro_products");

    while(columns.next()){

    String prod_name = columns.getString("prod_name");
    String prod_class = columns.getString("prod_classification");
    String prod_sub_class = columns.getString("prod_sub_classification");
    %>
    <TR><TD> <%=prod_name%> </TD>
    <TD> <%=prod_class%> </TD>
    <TD> <%=prod_sub_class%> </TD>
    </TR>

    <% } %>
    </TABLE>
    </BODY>
    </HTML>
    [/PHP]

    I get the Following Error:

    "org.apache.jasper.JasperException: JZ004: User name property missing in DriverManager.getConnection(..., Properties)."

    I have tried to implement the following code.....

    [PHP]
    String strDBUser = "";
    String strDBPwd = "";
    String strDBUrl = "jdbc:sybase:Tds:BLAH:5000/BLAH";// database URL

    ......
    Properties props = new Properties();
    props.put("user", strDBUser);
    props.put("password", strDBPwd);
    [/PHP]

    ....... into

    [PHP]
    java.sql.Connection connection = java.sql.DriverManager.getConnection(strDBUrl, props);
    [/PHP]

    Can anyone see where I would put "Properties ". I've tried various combinations but cant get it. Can anyone help?

    Cheers in advance

    :)


Comments

  • Registered Users, Registered Users 2 Posts: 822 ✭✭✭Mutz


    No Matter!

    I found it! For the benefit of anyone else who may be in the same JSP/Sybase dilema soon:

    [PHP]
    <%@ page import= "java.sql.*" %>
    <%Class.forName("com.sybase.jdbc2.jdbc.SybDriver");%>
    <HTML>
    <HEAD><TITLE> Listing the Content of a Database</TITLE></HEAD>
    <BODY>
    <P> Content of the Product database:
    <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0>
    <TR><TD> Product Name </TD>
    <TD> Class </TD>
    <TD> Sub Class </TD>
    </TR>

    <%
    String theDatabase = "jdbc:sybase:Tds:BLAH:5000/BLAH";
    Connection connection = java.sql.DriverManager.getConnection(theDatabase,"Username","Password");
    Statement statement = connection.createStatement();
    ResultSet columns = statement.executeQuery("SELECT * FROM euro_products");

    while(columns.next()){

    String prod_name = columns.getString("prod_name");
    String prod_class = columns.getString("prod_classification");
    String prod_sub_class = columns.getString("prod_sub_classification");
    %>
    <TR><TD> <%=prod_name%> </TD>
    <TD> <%=prod_class%> </TD>
    <TD> <%=prod_sub_class%> </TD>
    </TR>

    <% } %>
    </TABLE>
    </BODY>
    </HTML>
    [/PHP]


Advertisement