wood burning stoves 2.0*
The moose likes JDBC and the fly likes Regarding Servlet connectivity with ms-access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Regarding Servlet connectivity with ms-access" Watch "Regarding Servlet connectivity with ms-access" New topic

Regarding Servlet connectivity with ms-access

sharma sachin

Joined: Nov 13, 2009
Posts: 24
I have created one simple Servlet file that insert the records in the database
I have used ms-access as back-end but when I try to insert the records it is giving an exception
that no data source name or default odbc driver not found
however same thing works when I try to insert the records using main() method on console
(means same concept works properly when I try to insert the records using swing form)
but using servlet it is giving an exception

Can anyone solve my query???
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 511
How are you connecting to the datasource? I presume you must be using JDBC_ODBC driver, can you please share the part of the code that connects to the database?
Also post the exception. After looking at it we might be able to get some clue.

sharma sachin

Joined: Nov 13, 2009
Posts: 24

the above code generates an exception:
exception=java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

however same dsn works while connecting the swing form with MS-ACCESS
means data is inserting successfully while using the swing form
anirudh jagithyala
Ranch Hand

Joined: Dec 07, 2010
Posts: 41
Did you create user DSN with only name hello and select the corresponding .mdb database....

PreparedStatement pstmt=con.prepareStatement("insert into myTable values(?,?)");

The prpared statement needs to be given values before its executed....

between line 24 and 25

If you are using vista sometimes you would get driver problems , i had a similar issue which worked in other windows OS but not vista
try updating drivers.

Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Lets start debugging to find where this little code giving you an stupid error.

To create and DSN please follow 'Control Panel ->Administrative tools ->Data Sources(ODBC) ->System DSN ->Add'
and make sure to create system DSN instead of user.

[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
I agree. Here's the link: http://aspose.com/file-tools
subject: Regarding Servlet connectivity with ms-access
Similar Threads
Converting a String to Clob for insert into DB
use of CLOB,help me.
SQLException. Generel Error
How to insert records in ms-access table using jdbc console application.
Insert into MS Access with PreparedStatement