Results 1 to 14 of 14

Thread: Issue with JDBC Connection

Hybrid View

  1. #1
    Join Date
    Nov 2006

    Issue with JDBC Connection


    I have some issues to connect with the Database. I m using Oracle....
    I have a Login page page..when I type the user name and password it will go to the Home.jsp page. It is workingfine at my end.. However, when i tried in client machine, it wont. I have given some log files to check where the issue persists.. It fails at DriverManager.getConnection("jdbcracle:thin:@......)..Previously it works fine there... didnt get any error message. It hangs there.....When I click on Login button, it tries to load the page and hangs there.....it prints the logs given before the getConnection......
    whether it is an issue with Oacle JDBC Driver?????
    Help me.......


  2. #2
    Join Date
    Aug 2005
    The Garden State
    well what error is it giving? unable to find class?
    Acceptable Use | SQL Forum FAQ | celery is tasteless | twitter

    celery is tasteless - currently needing some UI time

  3. #3
    Join Date
    Nov 2006
    Didnt get any reply. Browser is trying to load and it hangs there.....I waited for more than 10 mts. thn lso browser is trying to load....i have used a TestJdbc java file to check the JDBC driver. first of all I tried that java file in my PC. It works fine and got the output if the Connection is there.... But in client machine, it wont give ny result....the same thing.......what haapened in the Browser..

  4. #4
    Join Date
    Aug 2005
    The Garden State
    I'm confused. Are you using servlets/jsps or something like that? How do you execute it on your client and over the browser, basically?

    You need make sure that your classpath has the oracle jdbc drivers in it. what web server are you using?
    Acceptable Use | SQL Forum FAQ | celery is tasteless | twitter

    celery is tasteless - currently needing some UI time

  5. #5
    Join Date
    Nov 2006
    Ok .Will explain it clearly. I am using JSP. I have a Login.jsp page. Here I will provide the user name and password. And it will goes to CheckLogin.jsp. Here the databse connetion comes. Using Oracle database. and Jdbc thin driver. but it wont connet to the Database.

    I have given log files to check where the issue persists..
    Connection con=DriverManager.getConnection("....");

    Like that I have provided..I have used Log4J for printing the log file.
    After I run the jsp program, it prints 1st aand 2nd in the log file.

    After that, it didnt print the 3rd or what the log I provided in the catch block.

    After the Class.forName (), there is some issue with DriverManager.getConnetion....it is working at my end....
    the issue is with only the client system ...Previously it was working fine in the client system also....
    When I enter the user name and password in the Browser, it will goes to the CheckLogin.jsp and trying to load and then nothing happens. Trying to read....
    Didnt get any error message. Browser trying load and I have waited for more than 10 mts...then also the same status ...trying to read....

    there is no issue with the code as it is working fine in my end and i tried it in a testing machine also.. There also it works fine... But in client system it is not working.. previously it was working there without any issue....So whether it is anissue with the JDBC driver or Database????
    How can I install the Oracle Jdbc thin Driver??? From where I can downlaod it????

    Plzz help mee...

    thanx for your reply.................

  6. #6
    Join Date
    Aug 2005
    The Garden State
    It sounds like your client system has a different classpath than you do.

    You can probably download the oracle jdbc from oracle.com.
    Acceptable Use | SQL Forum FAQ | celery is tasteless | twitter

    celery is tasteless - currently needing some UI time

  7. #7
    Join Date
    Nov 2006
    Previously it was working fine....so i think it is not the issue with the classpath...

  8. #8
    Join Date
    Aug 2006
    Here is something I have used

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*" %>
    <%! Connection con=null; %>
    <%!Statement st = null;%>
    <%!ResultSet rs = null;%>
    <head><title>This is a JSP/DBConnect Example</title></head>
    	out.println("Query Output<br><br>");
    	try {
    		Class.forName("com.mysql.jdbc.Driver").newInstance(); //Add your driver here
    	} catch (ClassNotFoundException ce) {
    	try {
    		con = DriverManager.getConnection(
    		"jdbc:mysql://localhost/JSP", "user_name", "User_pass");
    		st = con.createStatement();
    		rs = st.executeQuery("SELECT * FROM user");
    		while (rs.next()) {
    			int uid = rs.getInt(1);
    			String lName = rs.getString(3);
    			String fName = rs.getString(2);
    			out.println(uid + " " + lName + " " + fName + "<br>");
    		} // end of while
    	} catch (SQLException exception) {
    		StringWriter sw = new StringWriter();
    		PrintWriter pw = new PrintWriter(sw);
        if (request.getHeader("HTTP_X_FORWARDED_FOR") == null) {
            String ipaddress = request.getRemoteAddr();
            out.println("Your IP is:" + ipaddress + "<br>" + "Proxy Status: NO");
        } else {
            String ipaddress = request.getHeader("HTTP_X_FORWARDED_FOR");
            out.println("Your IP is:" + ipaddress + "<br>" + "Proxy Status: YES");
    I am connecting to a MySQL DB using xampp for testing. This is a DBConnect.jsp test file

  9. #9
    Join Date
    Dec 2002
    Calgary, Canada
    Post the complete error before I jump to conclusions..:-)
    Last edited by Khalid Ali; 12-18-2006 at 03:18 PM.


    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  10. #10
    Join Date
    Nov 2006
    thnx for your reply.

    I have tried a JdbcCheckUp.java to check the Driver connection. It is workin at my end.. But when I compiled in client machine, didnt work.....
    when I provide database, user name and password, it tries to check and nothing happens.....tryin..trying...after10 mts also...its trying....didnt get any error message or anything....it wont exit from the Command Prompt or didnt show any error message.......

    Here I provided the JdbcCheckUp.java

    * This sample can be used to check the JDBC installation.
    * Just run it and provide the connect information. It will select
    * "Hello World" from the database.
    * note: jdk1.2 is recommanded. jdk1.1 will also work

    // You need to import the java.sql package to use JDBC
    import java.sql.*;

    // We import java.io to be able to read from the command line
    import java.io.*;

    class JdbcCheckup
    public static void main (String args [])
    throws SQLException, IOException
    // Load the Oracle JDBC driver
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());

    // Prompt the user for connect information
    System.out.println ("Please enter information to test connection to the database");
    String user;
    String password;
    String database;

    user = readEntry ("user: ");
    int slash_index = user.indexOf ('/');
    if (slash_index != -1)
    password = user.substring (slash_index + 1);
    user = user.substring (0, slash_index);
    password = readEntry ("password: ");
    database = readEntry ("database (a TNSNAME entry, name-value pairs): ");

    System.out.print ("Connecting to the database...");
    System.out.flush ();

    // Connect to the database
    // You can put a database name after the @ sign in the connection URL.

    System.out.println ("Connecting...");
    Connection conn =
    DriverManager.getConnection ("jdbcracleci8:@" + database,
    user, password);

    System.out.println ("connected.");

    // Create a statement
    Statement stmt = conn.createStatement ();

    // Do the SQL "Hello World" thing
    ResultSet rset = stmt.executeQuery ("select 'Hello World' from dual");

    while (rset.next ())
    System.out.println (rset.getString (1));

    System.out.println ("Your JDBC installation is correct.");

    // close the resultSet

    // Close the statement

    // Close the connection

    // Utility function to read a line from standard input
    static String readEntry (String prompt)
    StringBuffer buffer = new StringBuffer ();
    System.out.print (prompt);
    System.out.flush ();
    int c = System.in.read ();
    while (c != '\n' && c != -1)
    buffer.append ((char)c);
    c = System.in.read ();
    return buffer.toString ().trim ();
    catch (IOException e)
    return "";

  11. #11
    Join Date
    Dec 2002
    Calgary, Canada
    sorry can not really go through all of the code, do 1 thing for me. Put debugging statements at
    1.once the driver class is loaded
    2.connections is created
    3. query is run
    4. and the after the the result set completes the loop
    and see which part hangs it. post your results


    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  12. #12
    Join Date
    Nov 2006
    The above Java file I used for checking the Jdbc connection only. Actually, I am using a jsp page....There I got issue. In that I have provided log files to check where the issue persists(log4J).....
    I have provided log files before and after the DriverManager.getConnection()....Also, in try catch block.....

    It prints log files till the DriverManager.getConnection()...ddnt print no log files after the getConnection().........

    and I understand that it fails on DriverManager.getConnection("....");.....So to check the Jdbc connection, I have used the JdbcCheck.java file. there also I got the issue...only in client machine.....

    whether it should be the issue with JdbcDriver or ?????
    As it works fine previously, it might not be the issue with the classpath.

    thnx for r reply....

  13. #13
    Join Date
    Dec 2002
    Calgary, Canada
    It can not be issue with the drivers (unless I misunderstood something). all jsp code is processed on the server. not at the client machine. so your issue is server related and its the issue where your server side code resides. your connection url should look like the one below
    "jdbcracleci8:@hostaddress:1521:SID", "userName", "password"


    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  14. #14
    Join Date
    Nov 2006
    i think some misunderstanding in our reply.....

    what the things we have installed or configured in our client's machine(for whom we have done this project-server) and the machine at my end are same.....it was workin fine at both the end previously....one week before the issue arises......they are not able to login to the home page....so we checked in our end...its working.....and thn we checked in our client's server machine...it is not workin.....

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.13914 seconds
  • Memory Usage 3,375KB
  • Queries Executed 13 (?)
More Information
Template Usage (30):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (14)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (14)postbit
  • (14)postbit_onlinestatus
  • (14)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (27):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./includes/functions_threadedmode.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (71):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates