/    Sign up×
Community /Pin to ProfileBookmark

Connection String (Access database on server)

Hi. I am trying to write a simple servlet to connect to an Access database stored on a server but I am having trouble with the connection string. (keep getting dsn too long error)

All the examples I have looked at connect to a database on a local machine but I do not want this!

Any help would be greatly appreciated. ?

to post a comment
Java

2 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliOct 23.2006 — show us the actual code u are using to connect to db..
Copy linkTweet thisAlerts:
@kp2authorOct 24.2006 — [CODE]import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ConnectAccess extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><head></head><title>Kevin's JDBC Access</title>" +"<BODY>n" +"<H2>Hello from the JDBC Access</H2>n");

int i;
Connection conn = null;

// loading jdbc driver for access
try{
// System.out.println("Trying to load driver");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
} catch(Exception e) {
System.out.println(e);
}

System.out.println("loaded driver");

// connecting to database
try{
// connection string for database
conn = DriverManager.getConnection
("jdbc:odbc://mudfoot.doc.stu.mmu.ac.uk:3306/porterk?user=******&password=*******/db1.mdb");
System.out.println("Connection to database successful.");
}
catch(SQLException se) {
System.out.println(se);
}
[/CODE]
×

Success!

Help @kp2 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...