Results 1 to 10 of 10
- 08-03-2012, 08:27 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 57
- Rep Power
- 0
Direct Access Connectivity with password
Hello Guys
I'm direct access connectivity its working but when i'm gonna set password on access database i'm getting nullpointerexception
here is the code:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String filename = "database/data.mdb";
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
database += filename.trim()+";DriverID=22;READONLY=true";
con = DriverManager.getConnection(database, "", "java");
please help
- 08-06-2012, 10:29 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Direct Access Connectivity with password
Where are you getting the null pointer exception?
Please do not ask for code as refusal often offends.
- 08-07-2012, 11:15 AM #3
Member
- Join Date
- Dec 2010
- Posts
- 57
- Rep Power
- 0
Re: Direct Access Connectivity with password
I'm getting exception here
Connection con = DriverManager.getConnection(database, "", "java");
what's the problem can you help me
- 08-07-2012, 11:19 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Direct Access Connectivity with password
You'll need to give us the stack trace, as there's nothing on that line that would be null.
Please do not ask for code as refusal often offends.
- 08-08-2012, 09:47 PM #5
Member
- Join Date
- Dec 2010
- Posts
- 57
- Rep Power
- 0
Re: Direct Access Connectivity with password
Here is exception
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at DatabaseManager.getPassword(DatabaseManager.java:4 84)
at JPasswordPanel.showPanel(JPasswordPanel.java:31)
at Main$1.run(Main.java:43)
at java.awt.event.InvocationEvent.dispatch(Invocation Event.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:705)
at java.awt.EventQueue.access$000(EventQueue.java:101 )
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 675)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:90)
- 08-09-2012, 09:30 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Direct Access Connectivity with password
And the code for getPassword, highlighting line 484.
Because if it's that line then either you have an object called DriverManager which is null (rather than using the static getCOnnection() method on the class), or you are not running the code you think you are.Please do not ask for code as refusal often offends.
- 08-10-2012, 02:04 PM #7
Member
- Join Date
- Dec 2010
- Posts
- 57
- Rep Power
- 0
Re: Direct Access Connectivity with password
I'm using static block for connectivity
DatabaseManager{
static Conncetion con;
static{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String filename = "database/data.mdb";
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
database += filename.trim()+";DriverID=22;READONLY=true";
con = DriverManager.getConnection(database, "", "java");
}
public static String getPassword() throws SQLException{
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("SELECt * from password");
if(rs.next()){
return rs.getString("pass");
}
return "";
}
}
And in DriverManager.getConnection(database, "", "java"); initializing the null value in Connection bbject
if I removing the pass word from ms access db the prgram is running but witgh its not working...
now understand
- 08-10-2012, 02:33 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Direct Access Connectivity with password
When posting code please use [code] tags [/code].
So, con is null.
Which implies that the static initialiser is throwing an exception.
Now, since you would not be able to compile the above without a try/catch block to handle the SQLException that getConnection() throws, I am guessing the above is not your actual code and that your actual code catches the SQLException and does nothing with it. Or you are ignoring it in your logs.Please do not ask for code as refusal often offends.
- 08-10-2012, 04:43 PM #9
Member
- Join Date
- Dec 2010
- Posts
- 57
- Rep Power
- 0
Re: Direct Access Connectivity with password
sorry for [code] tags
sorry, i didn't write try-catch block in post.
now Its giving me this exception
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Not a valid password.
im writing correct password
- 08-10-2012, 05:05 PM #10
Member
- Join Date
- Dec 2010
- Posts
- 57
- Rep Power
- 0
Similar Threads
-
Protect Workbook from Unauthorized Access by Assigning Password in Cloud
By saaspose in forum Java SoftwareReplies: 0Last Post: 07-31-2012, 08:33 AM -
connect to password protected access database
By Yama12 in forum JDBCReplies: 0Last Post: 09-14-2011, 09:44 AM -
access database connectivity from outside an application
By suchirag in forum JDBCReplies: 5Last Post: 10-29-2009, 07:56 AM -
DSN less connectivity to Ms ACCESS
By sayan751 in forum Advanced JavaReplies: 2Last Post: 03-28-2009, 04:27 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks