Results 1 to 8 of 8
  1. #1
    chyeeqi is offline Member
    Join Date
    Aug 2009
    Posts
    23
    Rep Power
    0

    Default face problem to read data from microsoft access

    i have the error of
    problem connecting to jdbc:odbc:testdb

    testdb is my database file name..how can i fix the error???

    i face the probelm at here
    Java Code:
    String URL = "jdbc:odbc:testdb";//Change data source name.
            String username = "";
            String password = "";
    Attached Thumbnails Attached Thumbnails face problem to read data from microsoft access-untitled.jpg  

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    841
    Rep Power
    6

    Default

    Hi,
    Have you mapped ur db with dsn like this below.

    Goto Control panel and select Administrative Tools -> Data Sources(ODBC) -> you will get a window "ODBC DataSource Administrator".

    In the above window select Add button then you will get "Create New Data Source" window.In that list you need to select "Driver do Microsoft Access(*.mdb)" option and the click "Finish" button. Then,you will get "ODBC Microsoft Access set up" window.

    In the above window enter "Data Source Name" as any name which u have to use it in your program.Then click "Select" button.U have to map this name to db file by selecting the location.

    So the above mapped DSN name only u need to give in ur code as jdbc:odbc:dsnName.

    Do the above steps and let me know if u get problems.
    Ramya:cool:

  3. #3
    chyeeqi is offline Member
    Join Date
    Aug 2009
    Posts
    23
    Rep Power
    0

    Default

    i alrady done that setting....but having the same problem....

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    841
    Rep Power
    6

    Default

    Send the java execption by calling printStackTrace and also send the code.
    Are u refering the datasource name properly?
    Ramya:cool:

  5. #5
    chyeeqi is offline Member
    Join Date
    Aug 2009
    Posts
    23
    Rep Power
    0

    Default

    this is my code...help me where got problem
    Java Code:
    import java.sql.*;
    import java.io.*;
    
    
    public class Search {
        public static void main (String args[]) throws IOException{
    	BufferedReader br=new BufferedReader (new InputStreamReader(System.in));
            String URL = "jdbc:odbc:testdb";//Change data source name.
            String username = "";
            String password = "";
    
            try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            } catch (Exception e) {
                System.out.println("Failed to load JDBC/ODBC:dsnName.");
                return;
            }
    
            Statement stmt = null;
            Connection con=null;
            try {
                con = DriverManager.getConnection (
                    URL,
                    username,
                    password);
                stmt = con.createStatement();
            } catch (Exception e) {
                System.err.println("problems connecting to "+URL);
            }
    
           String input;
           input=br.readLine();
    
            try {
                ResultSet result = stmt.executeQuery(
                    "SELECT * FROM chee Where day='" + input + "'");//Select Query statement
                ResultSetMetaData meta = result.getMetaData();
    
    			//============================================================================
    			
    			//get all records
    			String programmer; 
    			double price;
    			while(result.next()) { 
    			   programmer= result.getString("programmer");
    			   price=result.getDouble("Price");
    			   
    			    
    			   System.out.println(programmer + "\n");
    			} 
    
    			//============================================================================
                con.close();
            }
            catch (Exception e) {
              e.printStackTrace();
            }
        }
    }

  6. #6
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    841
    Rep Power
    6

    Default

    Hi,
    U print the exception like

    e.printStackTrace() so that u can find the exact problem inside the exception block .

    Anyway you are not having userName and password know just use

    DriverManager.getConnection("jdbc:odbc:testdb");

    Crosscheck whether testdb is listed in userdsn and mapped to ur db file
    Ramya:cool:

  7. #7
    netrista is offline Member
    Join Date
    Aug 2007
    Posts
    4
    Rep Power
    0

    Default

    Hello,

    In addition to logging, as Ramya has suggested, I would add:

    1. Determine what JDK/JRE resources are on your Windows client.

    2. Ensure the local classpath SYSTEM and USER variables point to the correct JAVA resources.

    3. Ensure java <driver class> returns the correct driver info.

    4. Ensure the driver is compatible with your version of the JAVA resources.

    5. Sanity test your JDBC-ODBC bridge with a standard JDBC demo app.

    6. If the problem persists, perform parallel tests with 3rd-party ODBC drivers just to see if the problem is inherent to your current driver or generalized and probably indicative of some problem with your code or environment.

    Best regards,
    Netrista Khatam
    Technical Services Manager
    OpenLink Software

  8. #8
    chyeeqi is offline Member
    Join Date
    Aug 2009
    Posts
    23
    Rep Power
    0

Similar Threads

  1. Replies: 3
    Last Post: 12-01-2011, 06:40 AM
  2. Basic Face Application
    By adam87 in forum New To Java
    Replies: 6
    Last Post: 03-14-2008, 06:21 PM
  3. How to read the MAC of an Access Point
    By goodjonx in forum Networking
    Replies: 2
    Last Post: 12-19-2007, 11:31 AM
  4. Replies: 1
    Last Post: 08-07-2007, 07:51 AM
  5. connect to microsoft access
    By bbq in forum JDBC
    Replies: 1
    Last Post: 07-09-2007, 03:33 AM

Posting Permissions

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