Access databases can only be accessed by ODBC (default present at
2000 / XP). MySQL has nothing to do with it.
1) First create your Access database (.mdb, I don't know what a
Works database is?). It may be placed anywhere on your Tomcat Server.
2) Then configure it for usage by ODBC. Click Start -> Run:
%SystemRoot%\system32\odbcad32.exe
In the tab System-DSN make a new entry (I hope I translate well from
Dutch here).
2a) Give the entry a free-choosable unique name, for instance 'MyDatabase'
2b) Specify the path to the database you created in step 1)
3) Attach to the driver using:
// Load the driver, at some Virtual Machines
// newInstance() appears to be necessary
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ).newInstance();
4) Connect to the database using:
Connection newConnection = DriverManager.getConnection(
"jdbc:odbc:MyDatabase" );
Note: Microsoft - as usual - implemented some differences in SQL-syntax!
Sije de Haan,
Netherlands
At 09:59 29-5-2007, you wrote:
Hi,
This is getting more confusing, you mentioned earlier that you're
using MySQL but now it is a Microsoft Works Database. Hmmm perhaps
i'm missing something?
Anyway, if the database you're using is something like an Access
database, you'll just need to use the correct driver and point the
URL to your database file. Can't help you here coz i never tried
that before (Access is like from another world to me). Perhaps you
should try other mailing list, and not Tomcat's.
HTH
FooShyn
Teh Noranis Mohd Aris wrote:
Yes, the login name and password are correct. I created the
database name, teh, with field username and password, using
Microsoft Works Database and saved it in directory
catalina_home\webapps\ROOT\. I'm not sure whether it is the correct
directory to
put the database. However, in the program there was a statement
.....(insert into login_table values(?,?)"); I do not understand the
usage of login_table. Does it mean that I should create login_table
in database teh? Really need to get this working to
day. Please help. Thank you.
TEH
Foo Shyn <[EMAIL PROTECTED]> wrote:
Hi,
Is your login name and password correct? It shows 'root' and the
password is 'root' in the code you posted there.
- I put the database name, teh in directory catalina_home\webapps\ROOT\
hmm i can't really get what you meant here.
Thanx.
FooShyn
Teh Noranis Mohd Aris wrote:
Dear All,
I already put mysql database driver (jar file) in directory
catalina_home\common\lib and changed 8080 to 3306 but I got the
error "java.sql.SQLException: Unable to connect to any hosts due
to exception: java.net.ConnectException: Connection refused:
connect". What should be the matter? I put the database name, teh in
directory catalina_home\webapps\ROOT\. Is this correct? In which
directory should I actually put the database name? Please help. I'm
running out of time! Thank you so much.
Yours Sincerely,
TEH
Foo Shyn wrote:
Hi,
You'll need to get the MySQL database driver and put them in the
{catalina_home}\common\lib folder. The driver can be easily
obtained through MySQL site.
BTW, as far as i know, the default port for MySQL database is
3306, so you might wanna change that. 8080 is for Tomcat, not the database.
Seems like not many new users of connection pooling went through
Apache's documents. Please don't waste their effort, take a look
at it before you start to attempt anything.
HTH,
FooShyn
Teh Noranis Mohd Aris wrote:
Thank you so much for the reply. I've put
"jdbc:mysql://localhost:8080/teh but I got the error
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver. I'm very
new to using mysql database and servlet. Can you please explain
to me how to create the
database name and its fields? Should I install any driver? How can
it be done? Please help. Thank you.
Yours Sincerely,
TEH
Foo Shyn wrote:
Hi,
yyyy would be ur database port, xxx will be ur database name
HTH
FooShyn
Teh Noranis Mohd Aris wrote:
Hi,
I would like to access mysql database from a servlet but I'm not
sure what to initialize for the String connectionURL marked as
"jdbc:mysql://localhost:yyyy/xxx" in the program below. I got
this program from the internet which I would like to run i
n my computer. Can anyone please explain to me what the parameters
"yyyy" and "xxx" should be?
Yours Sincerely,
TEH
Following is part of the program:
.......
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
String connectionURL = "jdbc:mysql://localhost:yyyy/xxx";
Connection connection=null;
try{
String username = request.getParameter("username");
String password = request.getParameter("password");
pw.println(username);
pw.println(password);
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "root", "root");
PreparedStatement pst = connection.prepareStatement
("insert into login_table values(?,?)");
.......
---------------------------------
Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge to
see what's on, when.
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition. Version: 7.5.472 / Virus Database:
269.8.0/821 - Release Date: 5/27/2007 3:05 PM
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------
Shape Yahoo! in your own image. Join our Network Research Panel today!
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition. Version: 7.5.472 / Virus Database:
269.8.0/821 - Release Date: 5/27/2007 3:05 PM
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------
Take the Internet to Go: Yahoo!Go puts the Internet in your
pocket: mail, news, photos & more.
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition. Version: 7.5.472 / Virus Database:
269.8.0/821 - Release Date: 5/27/2007 3:05 PM
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------
Choose the right car based on your needs. Check out Yahoo! Autos
new Car Finder tool.
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition. Version: 7.5.472 / Virus Database:
269.8.0/821 - Release Date: 5/27/2007 3:05 PM
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
__________ NOD32 2294 (20070528) Informatie __________
Dit bericht is gecontroleerd door het NOD32 Antivirus Systeem.
http://www.nod32.nl