Using servlet and mysql

2007-05-28 Thread Teh Noranis Mohd Aris
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:/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 "" 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:/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. 

Re: Using servlet and mysql

2007-05-28 Thread Foo Shyn

Hi,

 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:/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 "" 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:/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]



Re: Using servlet and mysql

2007-05-28 Thread Teh Noranis Mohd Aris
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 <[EMAIL PROTECTED]> wrote:
  Hi,

 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:/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 "" 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:/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!

Re: Using servlet and mysql

2007-05-28 Thread Zachary Grafton
On Tuesday 29 May 2007 01:14, 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 <[EMAIL PROTECTED]> wrote:
>   Hi,
>
>  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:/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 "" 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:/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!

There are many great tutorials on the web on how to do this, here is a url 
with the basic servlet code:

http://www.cs.unc.edu/Courses/comp118/docs/lessons/java/java_jdbc/jdbcServletMysql.html

That page however doesn't tell you that you need to place the mysql 
driver(which should be a jar file) in your web application's WEB-INF/lib 
folder.


Good Luck,

Zack

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using servlet and mysql

2007-05-28 Thread Foo Shyn

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 <[EMAIL PROTECTED]> wrote:
  Hi,

 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:/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 "" 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:/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]



Re: Using servlet and mysql

2007-05-28 Thread Teh Noranis Mohd Aris
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 <[EMAIL PROTECTED]> 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,
>
>  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:/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 "" 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:/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. 

Re: Using servlet and mysql

2007-05-29 Thread Foo Shyn

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 <[EMAIL PROTECTED]> 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,

 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:/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 "" 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:/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]



Re: Using servlet and mysql

2007-05-29 Thread Teh Noranis Mohd Aris
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 <[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,
>>
>>  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:/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 "" 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:/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]
>
>

Re: Using servlet and mysql

2007-05-29 Thread Foo Shyn

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 <[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,

 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:/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 "" 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:/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




Re: Using servlet and mysql

2007-05-29 Thread Teh Noranis Mohd Aris
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 <[EMAIL PROTECTED]> 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,
>>>
>>>  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:/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 "" 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:/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. 

 ---

Re: Using servlet and mysql

2007-05-29 Thread Foo Shyn

Hi,

In short, to get a MySQL server up, try the following:
1) Install an instance of MySQL
2) Install the client software (you can get them from the MySQL web site 
too, like MySQL Administrator etc or you can try the MySQL Front for 
older version of MySQL)

3) Create a database using the client software.
4) Put the MySQL drivers in the common\lib folder(if you want it to be 
global) or in your WEB-INF\lib folder (if you want it to be local)

5) Run the Tomcat, try your code

Not sure whether this is good enough, perhaps someone with better 
explanation skill can explain it better than me.

Remember google is always your best friend. :)

HTH,
FooShyn

Teh Noranis Mohd Aris wrote:

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 <[EMAIL PROTECTED]> 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,

 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:/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 "" 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:/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.D

Re: Using servlet and mysql

2007-05-29 Thread De Haan Software Engineering


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,

 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:/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 
"" 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:/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 = connect

Re: Using servlet and mysql

2007-05-29 Thread David Smith
I would actually recommend steering clear of the jdbc-odbc bridge
driver.  It's not stable enough for production use on any level.

Get MySQL (it's free), install it, configure it according to the docs
and setup your db there.  Docs are plentiful on the mysql website.  You
will be much happier with the end result.

--David


De Haan Software Engineering wrote:
>
> 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.
>>>
>>>  


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using servlet and mysql

2007-05-29 Thread De Haan Software Engineering


I agree completely. For testing purposes or migration it works. We 
are switching to MySQL asap, but dozens of customers are still using it...


Sije

At 14:38 29-5-2007, you wrote:

I would actually recommend steering clear of the jdbc-odbc bridge
driver.  It's not stable enough for production use on any level.

Get MySQL (it's free), install it, configure it according to the docs
and setup your db there.  Docs are plentiful on the mysql website.  You
will be much happier with the end result.

--David


De Haan Software Engineering wrote:
>
> 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.
>>>
>>>


-
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 2295 (20070529) Informatie __

Dit bericht is gecontroleerd door het NOD32 Antivirus Systeem.
http://www.nod32.nl