tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Teh Noranis Mohd Aris <teh_nora...@yahoo.com>
Subject Re: Using servlet and mysql
Date Tue, 29 May 2007 08:09:48 GMT
I'm very new to this. This is the first time I'm using mysql and servlet. I might be doing
a lot of mistakes. I realized that I should not use Microsoft Works Database. How can I actually
create the database name, table and its field using mysql? In which directory should I put
the database? Please explain. Hoping for a reply. I really hope this simple program can run
today. Thank you.
   
  TEH

Foo Shyn <fooshyn@optegra.com.my> 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 today. Please help. Thank you.
> 
> TEH
> 
>
> Foo Shyn 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 in 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: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>>
>>> ---------------------------------
>>> 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: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>>
>> ---------------------------------
>> 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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
> 
> ---------------------------------
> 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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



 
---------------------------------
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message