From users-return-163779-apmail-tomcat-users-archive=tomcat.apache.org@tomcat.apache.org Tue May 29 08:42:14 2007 Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 33652 invoked from network); 29 May 2007 08:42:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 May 2007 08:42:13 -0000 Received: (qmail 94561 invoked by uid 500); 29 May 2007 08:42:03 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 94253 invoked by uid 500); 29 May 2007 08:42:02 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 94236 invoked by uid 99); 29 May 2007 08:42:01 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 May 2007 01:42:01 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [213.51.130.200] (HELO smtpq1.groni1.gr.home.nl) (213.51.130.200) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 May 2007 01:41:55 -0700 Received: from [213.51.130.189] (port=48857 helo=smtp2.groni1.gr.home.nl) by smtpq1.groni1.gr.home.nl with esmtp (Exim 4.30) id 1HsxGm-0004jO-IC for users@tomcat.apache.org; Tue, 29 May 2007 10:41:32 +0200 Received: from cc961561-a.gorre1.fr.home.nl ([217.120.148.210]:60163 helo=VMINTERNET.dehaansoftware.nl) by smtp2.groni1.gr.home.nl with esmtp (Exim 4.30) id 1HsxGk-000451-IT for users@tomcat.apache.org; Tue, 29 May 2007 10:41:30 +0200 X-Mailer: QUALCOMM Windows Eudora Version 7.1.0.9 Date: Tue, 29 May 2007 10:41:06 +0200 To: "Tomcat Users List" From: De Haan Software Engineering Subject: Re: Using servlet and mysql In-Reply-To: <465BDD59.4020908@optegra.com.my> References: <498565.92482.qm@web53807.mail.re2.yahoo.com> <465BDD59.4020908@optegra.com.my> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=====================_545711734==.ALT" X-AtHome-MailScanner-Information: Neem contact op met support@home.nl voor meer informatie X-AtHome-MailScanner: Found to be clean X-Virus-Checked: Checked by ClamAV on apache.org Message-Id: <20070529084156.CDB5210FB004@herse.apache.org> --=====================_545711734==.ALT Content-Type: text/plain; charset="us-ascii"; format=flowed 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 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: 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 > > >__________ NOD32 2294 (20070528) Informatie __________ > >Dit bericht is gecontroleerd door het NOD32 Antivirus Systeem. >http://www.nod32.nl > --=====================_545711734==.ALT--