Results 1 to 8 of 8
- 08-20-2009, 11:22 AM #1
Member
- Join Date
- Aug 2009
- Posts
- 23
- Rep Power
- 0
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 = "";
- 08-20-2009, 11:31 AM #2
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:
- 08-20-2009, 11:42 AM #3
Member
- Join Date
- Aug 2009
- Posts
- 23
- Rep Power
- 0
i alrady done that setting....but having the same problem....
- 08-20-2009, 11:49 AM #4
Send the java execption by calling printStackTrace and also send the code.
Are u refering the datasource name properly?Ramya:cool:
- 08-20-2009, 12:03 PM #5
Member
- Join Date
- Aug 2009
- Posts
- 23
- Rep Power
- 0
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(); } } }
- 08-20-2009, 12:20 PM #6
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 fileRamya:cool:
- 08-20-2009, 08:32 PM #7
Member
- Join Date
- Aug 2007
- Posts
- 4
- Rep Power
- 0
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
- 08-21-2009, 01:08 PM #8
Member
- Join Date
- Aug 2009
- Posts
- 23
- Rep Power
- 0
Similar Threads
-
Accessing a remote Microsoft Access database
By ajeeb in forum JDBCReplies: 3Last Post: 12-01-2011, 06:40 AM -
Basic Face Application
By adam87 in forum New To JavaReplies: 6Last Post: 03-14-2008, 06:21 PM -
How to read the MAC of an Access Point
By goodjonx in forum NetworkingReplies: 2Last Post: 12-19-2007, 11:31 AM -
Help with access a database using Microsoft Access
By cachi in forum JDBCReplies: 1Last Post: 08-07-2007, 07:51 AM -
connect to microsoft access
By bbq in forum JDBCReplies: 1Last Post: 07-09-2007, 03:33 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks