Re: Name jdbc is not bound in this Context error
Hi Antony, I downloaded postgres and installed on my m/c. I installed it as a service. Can you pls give step by step instruction as how to connect to postgresql database. Thank you so much. --- Antony Paul [EMAIL PROTECTED] wrote: You can name it the name of the context(web). The content should be similar to any other file there. I am giving a sample Context docBase=${catalina.home}/webapps/web antiResourceLocking=false antiJARLocking=false /Context rgds Antony Paul On Mon, 21 Feb 2005 23:18:55 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: Thanks for the replies. What do u mean by the following in ur erlier mail. Did you defined your newly created context web in server.xml or at TOMCAT_HOME\conf\Catalina\localhost\some name.xml Does it mean i need to create a new xml file in TOMCAT_HOME\conf\Catalina\localhost? What should be it's name? What should it contain? Pls let me know. I will try that. I didn't create any file there. Thanks again. hope it will help. rgds Antony Paul On Mon, 21 Feb 2005 22:25:59 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: Yes i read and did as per the document. When it didn't work, i followed the suggetions given to many users in the mailing lists in the internet and now i guess i messed up. Actually in the error, it says, no suitable driver found. I'm using Ms Access as it's free. Do we have any free driver available in the form of jar to use in place of JDBC-ODBC bridge driver? Or it's not required if configuration is correct. Pls let me know. I've pasted all relevant code in my first mail itself. If time permits, any of you can try give me the solution. It'll be a great help. I've integrated tomcat 5.5.7 with apache 2. Does this has any impact on the above. --- Antony Paul [EMAIL PROTECTED] wrote: If you followed the tomcat docs you will have no problem in DBCP getting to work. Going for Globalnamingresources is needed if you need to access it will all applications. Try to configure it as per the doc in following URL. http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html follow MySQL config. And no need to put commons*.jar in commons/lib as TC by default comes with it. rgds Antony Paul On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: I tried without GlobalNamingResources. No luck. When googled, i found that if we include GlobalNamingResource tag, then it will be available in all web context. After spending enough time on that, now i === message truncated === __ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? The all-new My Yahoo! - What will yours do? http://my.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Name jdbc is not bound in this Context error
In fact I hadnt installed it in windlws. You can connect to server suing psql. it will be in the bin directory. There is one GUI front end available PgAdmin. The documentation will be in doc directory. This contains installation, administration and tutorials on SQL. For further you can ask questions at PostgreSQL mailing lists(http://www.postgresql.org/community/lists/). rgds Antony Paul On Tue, 22 Feb 2005 02:07:20 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: Hi Antony, I downloaded postgres and installed on my m/c. I installed it as a service. Can you pls give step by step instruction as how to connect to postgresql database. Thank you so much. --- Antony Paul [EMAIL PROTECTED] wrote: You can name it the name of the context(web). The content should be similar to any other file there. I am giving a sample Context docBase=${catalina.home}/webapps/web antiResourceLocking=false antiJARLocking=false /Context rgds Antony Paul On Mon, 21 Feb 2005 23:18:55 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: Thanks for the replies. What do u mean by the following in ur erlier mail. Did you defined your newly created context web in server.xml or at TOMCAT_HOME\conf\Catalina\localhost\some name.xml Does it mean i need to create a new xml file in TOMCAT_HOME\conf\Catalina\localhost? What should be it's name? What should it contain? Pls let me know. I will try that. I didn't create any file there. Thanks again. hope it will help. rgds Antony Paul On Mon, 21 Feb 2005 22:25:59 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: Yes i read and did as per the document. When it didn't work, i followed the suggetions given to many users in the mailing lists in the internet and now i guess i messed up. Actually in the error, it says, no suitable driver found. I'm using Ms Access as it's free. Do we have any free driver available in the form of jar to use in place of JDBC-ODBC bridge driver? Or it's not required if configuration is correct. Pls let me know. I've pasted all relevant code in my first mail itself. If time permits, any of you can try give me the solution. It'll be a great help. I've integrated tomcat 5.5.7 with apache 2. Does this has any impact on the above. --- Antony Paul [EMAIL PROTECTED] wrote: If you followed the tomcat docs you will have no problem in DBCP getting to work. Going for Globalnamingresources is needed if you need to access it will all applications. Try to configure it as per the doc in following URL. http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html follow MySQL config. And no need to put commons*.jar in commons/lib as TC by default comes with it. rgds Antony Paul On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: I tried without GlobalNamingResources. No luck. When googled, i found that if we include GlobalNamingResource tag, then it will be available in all web context. After spending enough time on that, now i === message truncated === __ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? The all-new My Yahoo! - What will yours do? http://my.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Name jdbc is not bound in this Context error
It seems you still have problem. You can google for the answer. One thing I know is GlobalNamingResources should come inside the Server element and not inside Context element. rgds Antony Paul On Fri, 18 Feb 2005 22:47:06 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: I could able to get thro' JarperException. Thanks for replies. Now facing new problem. I'm getting NameNotFoundException - Name jdbc is not bound in this Context Environment what i'm using is: Apache 2, Tomcat 5.5, Netscape 7.2, MsAccess 2003 on windows 2000 machine. I integrated tomcat and apache as apache doesn't support jsps. I wrote a JSP called test-db.jsp which in turn calls java program TestSQLLoad.java. This TestSQLLoad.java performs dattabase operation, fetches the data from table and that data is displayed on Netscape thro' jsp. 1. test-db.jsp resides ina directory TOMCAT_HOME/webapps/web/JSP. Contents are as follows: %@ page contentType=text/html import=testpkg.TestSQLLoad% html head titleDB Test/title /head body % TestSQLLoad tst = new TestSQLLoad(); tst.init(); % h2Results/h2 User - %= tst.getUser() %br/ Pwd - %= tst.getPassword() %br/ Id - %= tst.getID() % /body /html 2. TestSQLLoad.java is residing in following directory. TOMCAT_HOME/webapps/web/classes/testpkg direcotry. Contents of this file are as follows: package testpkg; import javax.naming.*; import javax.sql.*; import java.sql.*; public class TestSQLLoad { String user = Not Connected; String pwd = no pwd; int id = -1; public void init() { try{ Context ctx = new InitialContext(); if(ctx == null ) { throw new Exception(Boom - No Context); } Context envCtx = (Context) ctx.lookup(java:comp/env); DataSource ds = (DataSource) envCtx.lookup(jdbc/db1); //DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/db1); if (ds != null) { Connection conn = ds.getConnection(); if(conn != null) { user = Got Connection +conn.toString(); Statement stmt = conn.createStatement(); String q = select name, password, id from user; ResultSet rst = stmt.executeQuery(q); if(rst.next()) { user=rst.getString(1); pwd=rst.getString(2); id = rst.getInt(3); } conn.close(); } } }catch(Exception e) { e.printStackTrace(); } } public String getUser() { return user; } public String getPassword() { return pwd; } public int getID() { return id; } } 3. I created a jar file using testpkg directory put it in TOMCAT_HOME/common/lib as well as TOMCAT_HOME/webapps/web/WEB-INF/lib directory. 4. I created MsAccess database called db1.mdb and put it in TOMCAT_HOME/WEBAPPS/WEB/db1 directory. I created a table called user with fields name, password and ID. ID is the primary key. 5. I included following in the server.xml of TOMCAT_HOME/conf directory. Context path=/db1 docBase=C:/tomcat/webapps/db1 debug=5 reloadable=true crossContext=true GlobalNamingResources Resource name=jdbc/db1 auth=Container type=javax.sql.DataSource factory=org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory driverClassName=sun.jdbc.odbc.JdbcOdbcDrive url=jdbc:odbc://localhost/db1 maxActive=20 maxIdle=10 maxWait=-1 / /GlobalNamingResources /Context 6. I included following in context.xml of TOMCAT_HOME/conf directory. ResourceLink global=jdbc/db1 name=jdbc/db1 type=javax.sql.DataSource/ 7. I included following in web.xml of TOMCAT_HOME/webapps/web/WEB-INF directory. resource-ref res-ref-namejdbc/db1/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref 8. I copied commons-collections-2.1.1.jar, commons-dbcp-1.2.1.jar and commons-pool-1.2.jar into TOMCAT_HOME/common/lib directory. 9. I started apache, tomcat and then opened a browser and typed http://localhost/web/JSP/test-db.jsp. 10. I get following on the browser. Results User - Not Connected Pwd - no pwd Id - -1 11. On the tomcat window where tomcat is running i'm getting following error. javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:769) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.naming.factory.ResourceLinkFactory.getObjectInstance(Resou rceLinkFactory.java:96) at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source) at
Re: Name jdbc is not bound in this Context error
As just moved the GlobalNamingResources inside the main server in my server.xml residing in TOMCAT_HOME/conf directory. When i restart tomcat 5.5.7 it's throwing up following exception. INFO: Starting Servlet Engine: Apache Tomcat/5.5.7 Feb 22, 2005 11:51:46 AM org.apache.catalina.realm.UserDatabaseRealm start SEVERE: Exception looking up UserDatabase under key UserDatabase javax.naming.NameNotFoundException: Name UserDatabase is not bound in this Conte xt at org.apache.naming.NamingContext.lookup(NamingContext.java:769) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j ava:222) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440 ) at org.apache.catalina.core.StandardService.start(StandardService.java:4 50) at org.apache.catalina.core.StandardServer.start(StandardServer.java:683 ) at org.apache.catalina.startup.Catalina.start(Catalina.java:537) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409) Feb 22, 2005 11:51:46 AM org.apache.catalina.startup.Catalina start SEVERE: Catalina.start: LifecycleException: No UserDatabase component found under key UserDatabase at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j ava:228) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440 ) at org.apache.catalina.core.StandardService.start(StandardService.java:4 50) at org.apache.catalina.core.StandardServer.start(StandardServer.java:683 ) at org.apache.catalina.startup.Catalina.start(Catalina.java:537) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409) Feb 22, 2005 11:51:46 AM org.apache.catalina.startup.Catalina start INFO: Server startup in 391 ms Pls help to fix the problem. Thanks, Laxmi --- Antony Paul [EMAIL PROTECTED] wrote: It seems you still have problem. You can google for the answer. One thing I know is GlobalNamingResources should come inside the Server element and not inside Context element. rgds Antony Paul On Fri, 18 Feb 2005 22:47:06 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: I could able to get thro' JarperException. Thanks for replies. Now facing new problem. I'm getting NameNotFoundException - Name jdbc is not bound in this Context Environment what i'm using is: Apache 2, Tomcat 5.5, Netscape 7.2, MsAccess 2003 on windows 2000 machine. I integrated tomcat and apache as apache doesn't support jsps. I wrote a JSP called test-db.jsp which in turn calls java program TestSQLLoad.java. This TestSQLLoad.java performs dattabase operation, fetches the data from table and that data is displayed on Netscape thro' jsp. 1. test-db.jsp resides ina directory TOMCAT_HOME/webapps/web/JSP. Contents are as follows: %@ page contentType=text/html import=testpkg.TestSQLLoad% html head titleDB Test/title /head body % TestSQLLoad tst = new TestSQLLoad(); tst.init(); % h2Results/h2 User - %= tst.getUser() %br/ Pwd - %= tst.getPassword() %br/ Id - %= tst.getID() % /body /html 2. TestSQLLoad.java is residing in following directory. TOMCAT_HOME/webapps/web/classes/testpkg direcotry. Contents of this file are as follows: package testpkg; import javax.naming.*; import javax.sql.*; import java.sql.*; public class TestSQLLoad { String user = Not Connected; String pwd = no pwd; int id = -1; public void init() { try{ Context ctx = new InitialContext(); if(ctx == null ) { throw new Exception(Boom - No Context); } Context envCtx = (Context) ctx.lookup(java:comp/env); DataSource ds = (DataSource) envCtx.lookup(jdbc/db1); //DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/db1);
Re: Name jdbc is not bound in this Context error
By default server.xml contains have a GlobalNamingResources. You have to add your resources in there. rgds Antony Paul On Mon, 21 Feb 2005 19:56:23 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: As just moved the GlobalNamingResources inside the main server in my server.xml residing in TOMCAT_HOME/conf directory. When i restart tomcat 5.5.7 it's throwing up following exception. INFO: Starting Servlet Engine: Apache Tomcat/5.5.7 Feb 22, 2005 11:51:46 AM org.apache.catalina.realm.UserDatabaseRealm start SEVERE: Exception looking up UserDatabase under key UserDatabase javax.naming.NameNotFoundException: Name UserDatabase is not bound in this Conte xt at org.apache.naming.NamingContext.lookup(NamingContext.java:769) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j ava:222) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440 ) at org.apache.catalina.core.StandardService.start(StandardService.java:4 50) at org.apache.catalina.core.StandardServer.start(StandardServer.java:683 ) at org.apache.catalina.startup.Catalina.start(Catalina.java:537) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409) Feb 22, 2005 11:51:46 AM org.apache.catalina.startup.Catalina start SEVERE: Catalina.start: LifecycleException: No UserDatabase component found under key UserDatabase at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j ava:228) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440 ) at org.apache.catalina.core.StandardService.start(StandardService.java:4 50) at org.apache.catalina.core.StandardServer.start(StandardServer.java:683 ) at org.apache.catalina.startup.Catalina.start(Catalina.java:537) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409) Feb 22, 2005 11:51:46 AM org.apache.catalina.startup.Catalina start INFO: Server startup in 391 ms Pls help to fix the problem. Thanks, Laxmi --- Antony Paul [EMAIL PROTECTED] wrote: It seems you still have problem. You can google for the answer. One thing I know is GlobalNamingResources should come inside the Server element and not inside Context element. rgds Antony Paul On Fri, 18 Feb 2005 22:47:06 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: I could able to get thro' JarperException. Thanks for replies. Now facing new problem. I'm getting NameNotFoundException - Name jdbc is not bound in this Context Environment what i'm using is: Apache 2, Tomcat 5.5, Netscape 7.2, MsAccess 2003 on windows 2000 machine. I integrated tomcat and apache as apache doesn't support jsps. I wrote a JSP called test-db.jsp which in turn calls java program TestSQLLoad.java. This TestSQLLoad.java performs dattabase operation, fetches the data from table and that data is displayed on Netscape thro' jsp. 1. test-db.jsp resides ina directory TOMCAT_HOME/webapps/web/JSP. Contents are as follows: %@ page contentType=text/html import=testpkg.TestSQLLoad% html head titleDB Test/title /head body % TestSQLLoad tst = new TestSQLLoad(); tst.init(); % h2Results/h2 User - %= tst.getUser() %br/ Pwd - %= tst.getPassword() %br/ Id - %= tst.getID() % /body /html 2. TestSQLLoad.java is residing in following directory. TOMCAT_HOME/webapps/web/classes/testpkg direcotry. Contents of this file are as follows: package testpkg; import javax.naming.*; import javax.sql.*; import java.sql.*; public class TestSQLLoad { String user = Not Connected; String pwd = no pwd; int id = -1; public void init() { try{
Re: Name jdbc is not bound in this Context error
I tried without GlobalNamingResources. No luck. When googled, i found that if we include GlobalNamingResource tag, then it will be available in all web context. After spending enough time on that, now i coded all database related stuff in JSP in the way we do in stand alone application. I mean - Coding like this in jspo itself. code -- %@ page contentType=text/html import=java.sql.*% html headtitlesimmPlan - simple material planning system/title script language=JavaScript src=/js/default.js/script % String userid = request.getParameter(userid); String passwd = request.getParameter(passwd); System.out.println(Password: + passwd); String pwd = , str = ; int level = -1, ind = -1; try { Connection conn = null; Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); conn=DriverManager.getConnection(jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb); Statement stmt = conn.createStatement(); String query = SELECT * FROM user where name = ' + userid + '; ResultSet st = stmt.executeQuery(query); if (st.next()) { pwd = st.getString(password); level = st.getInt(level); System.err.println(Query result=+userid+/+pwd+/+level); } else { ind = -2; System.out.println(No user with name + userid + available in the database); } if (stmt != null) { stmt.close(); } if (conn != null) { conn.close(); } } catch (Exception e) { e.printStackTrace(); } if(pwd.equals(passwd)) { ind = level; } // else ind = -1; System.out.println(Ind - + ind); % script language=JavaScript type=text/JavaScript var ind = %= ind % function loadHtml() { //alert(in loadHtml()); if(ind == -2) { alert(Not a valid user); location.href = login.jsp; return; } if (ind == -1) { alert(Incorrect password); location.href = login.jsp; return; } else { //alert(Correct password); location.href = Second_Page.html; return; } } /script /head body onload=javascript:loadHtml() !-- User Name : %= userid %br Password : %= passwd % -- /body /html --- code ends here --- It works. But is it the right way to do? Pls advice. --- Antony Paul [EMAIL PROTECTED] wrote: By default server.xml contains have a GlobalNamingResources. You have to add your resources in there. rgds Antony Paul On Mon, 21 Feb 2005 19:56:23 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: As just moved the GlobalNamingResources inside the main server in my server.xml residing in TOMCAT_HOME/conf directory. When i restart tomcat 5.5.7 it's throwing up following exception. INFO: Starting Servlet Engine: Apache Tomcat/5.5.7 Feb 22, 2005 11:51:46 AM org.apache.catalina.realm.UserDatabaseRealm start SEVERE: Exception looking up UserDatabase under key UserDatabase javax.naming.NameNotFoundException: Name UserDatabase is not bound in this Conte xt at org.apache.naming.NamingContext.lookup(NamingContext.java:769) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j ava:222) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440 ) at org.apache.catalina.core.StandardService.start(StandardService.java:4 50) at org.apache.catalina.core.StandardServer.start(StandardServer.java:683 ) at org.apache.catalina.startup.Catalina.start(Catalina.java:537) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409) Feb 22, 2005 11:51:46 AM org.apache.catalina.startup.Catalina
Re: Name jdbc is not bound in this Context error
U K, It works as you said, but there are a couple of things I'll recommend: First, you should move your Connection, ResultSet and Statement declarations before the try {} block and add a finally {} block where you check for null values and close the resources if not null. Connection conn = null; Statement stmt = null; ResultSet res = null; try { .. } catch { } finally { if (stmt != null ) { try { stmnt.close(); } catch (SQLException se) { log.error(se.getMessage); } } Second, you should use a connection pool. I don't have a Tomcat config readily available. But can follow up with one if you need it. -Robert U K Laxmi wrote: I tried without GlobalNamingResources. No luck. When googled, i found that if we include GlobalNamingResource tag, then it will be available in all web context. After spending enough time on that, now i coded all database related stuff in JSP in the way we do in stand alone application. I mean - Coding like this in jspo itself. code -- %@ page contentType=text/html import=java.sql.*% html headtitlesimmPlan - simple material planning system/title script language=JavaScript src=/js/default.js/script % String userid = request.getParameter(userid); String passwd = request.getParameter(passwd); System.out.println(Password: + passwd); String pwd = , str = ; int level = -1, ind = -1; try { Connection conn = null; Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); conn=DriverManager.getConnection(jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb); Statement stmt = conn.createStatement(); String query = SELECT * FROM user where name = ' + userid + '; ResultSet st = stmt.executeQuery(query); if (st.next()) { pwd = st.getString(password); level = st.getInt(level); System.err.println(Query result=+userid+/+pwd+/+level); } else { ind = -2; System.out.println(No user with name + userid + available in the database); } if (stmt != null) { stmt.close(); } if (conn != null) { conn.close(); } } catch (Exception e) { e.printStackTrace(); } if(pwd.equals(passwd)) { ind = level; } // else ind = -1; System.out.println(Ind - + ind); % script language=JavaScript type=text/JavaScript var ind = %= ind % function loadHtml() { //alert(in loadHtml()); if(ind == -2) { alert(Not a valid user); location.href = login.jsp; return; } if (ind == -1) { alert(Incorrect password); location.href = login.jsp; return; } else { //alert(Correct password); location.href = Second_Page.html; return; } } /script /head body onload=javascript:loadHtml() !-- User Name : %= userid %br Password : %= passwd % -- /body /html --- code ends here --- It works. But is it the right way to do? Pls advice. --- Antony Paul [EMAIL PROTECTED] wrote: By default server.xml contains have a GlobalNamingResources. You have to add your resources in there. rgds Antony Paul On Mon, 21 Feb 2005 19:56:23 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: As just moved the GlobalNamingResources inside the main server in my server.xml residing in TOMCAT_HOME/conf directory. When i restart tomcat 5.5.7 it's throwing up following exception. INFO: Starting Servlet Engine: Apache Tomcat/5.5.7 Feb 22, 2005 11:51:46 AM org.apache.catalina.realm.UserDatabaseRealm start SEVERE: Exception looking up UserDatabase under key UserDatabase javax.naming.NameNotFoundException: Name UserDatabase is not bound in this Conte xt at org.apache.naming.NamingContext.lookup(NamingContext.java:769) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j ava:222) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440 ) at org.apache.catalina.core.StandardService.start(StandardService.java:4 50) at org.apache.catalina.core.StandardServer.start(StandardServer.java:683 ) at org.apache.catalina.startup.Catalina.start(Catalina.java:537) at
Re: Name jdbc is not bound in this Context error
If you followed the tomcat docs you will have no problem in DBCP getting to work. Going for Globalnamingresources is needed if you need to access it will all applications. Try to configure it as per the doc in following URL. http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html follow MySQL config. And no need to put commons*.jar in commons/lib as TC by default comes with it. rgds Antony Paul On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: I tried without GlobalNamingResources. No luck. When googled, i found that if we include GlobalNamingResource tag, then it will be available in all web context. After spending enough time on that, now i coded all database related stuff in JSP in the way we do in stand alone application. I mean - Coding like this in jspo itself. code -- %@ page contentType=text/html import=java.sql.*% html headtitlesimmPlan - simple material planning system/title script language=JavaScript src=/js/default.js/script % String userid = request.getParameter(userid); String passwd = request.getParameter(passwd); System.out.println(Password: + passwd); String pwd = , str = ; int level = -1, ind = -1; try { Connection conn = null; Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); conn=DriverManager.getConnection(jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb); Statement stmt = conn.createStatement(); String query = SELECT * FROM user where name = ' + userid + '; ResultSet st = stmt.executeQuery(query); if (st.next()) { pwd = st.getString(password); level = st.getInt(level); System.err.println(Query result=+userid+/+pwd+/+level); } else { ind = -2; System.out.println(No user with name + userid + available in the database); } if (stmt != null) { stmt.close(); } if (conn != null) { conn.close(); } } catch (Exception e) { e.printStackTrace(); } if(pwd.equals(passwd)) { ind = level; } // else ind = -1; System.out.println(Ind - + ind); % script language=JavaScript type=text/JavaScript var ind = %= ind % function loadHtml() { //alert(in loadHtml()); if(ind == -2) { alert(Not a valid user); location.href = login.jsp; return; } if (ind == -1) { alert(Incorrect password); location.href = login.jsp; return; } else { //alert(Correct password); location.href = Second_Page.html; return; } } /script /head body onload=javascript:loadHtml() !-- User Name : %= userid %br Password : %= passwd % -- /body /html --- code ends here --- It works. But is it the right way to do? Pls advice. --- Antony Paul [EMAIL PROTECTED] wrote: By default server.xml contains have a GlobalNamingResources. You have to add your resources in there. rgds Antony Paul On Mon, 21 Feb 2005 19:56:23 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: As just moved the GlobalNamingResources inside the main server in my server.xml residing in TOMCAT_HOME/conf directory. When i restart tomcat 5.5.7 it's throwing up following exception. INFO: Starting Servlet Engine: Apache Tomcat/5.5.7 Feb 22, 2005 11:51:46 AM org.apache.catalina.realm.UserDatabaseRealm start SEVERE: Exception looking up UserDatabase under key UserDatabase javax.naming.NameNotFoundException: Name UserDatabase is not bound in this Conte xt at org.apache.naming.NamingContext.lookup(NamingContext.java:769) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.j ava:222) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1003) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:440 ) at org.apache.catalina.core.StandardService.start(StandardService.java:4 50) at org.apache.catalina.core.StandardServer.start(StandardServer.java:683 ) at
Re: Name jdbc is not bound in this Context error
Sure to do the changes you mentioned. Pls do send the config file for connection pooling and also guidelines for how to use it in my program. It will be a great help. I'm developing web based application for using it inhouse. Later part of time, it may grow to a big MRP application based on the requirement of the company. If i go ahead with this kind of structure (the one i sent in my previous mail), does it cause any rpoblems? Pls advice. --- Robert F Hall [EMAIL PROTECTED] wrote: U K, It works as you said, but there are a couple of things I'll recommend: First, you should move your Connection, ResultSet and Statement declarations before the try {} block and add a finally {} block where you check for null values and close the resources if not null. Connection conn = null; Statement stmt = null; ResultSet res = null; try { .. } catch { } finally { if (stmt != null ) { try { stmnt.close(); } catch (SQLException se) { log.error(se.getMessage); } } Second, you should use a connection pool. I don't have a Tomcat config readily available. But can follow up with one if you need it. -Robert U K Laxmi wrote: I tried without GlobalNamingResources. No luck. When googled, i found that if we include GlobalNamingResource tag, then it will be available in all web context. After spending enough time on that, now i coded all database related stuff in JSP in the way we do in stand alone application. I mean - Coding like this in jspo itself. code -- %@ page contentType=text/html import=java.sql.*% html headtitlesimmPlan - simple material planning system/title script language=JavaScript src=/js/default.js/script % String userid = request.getParameter(userid); String passwd = request.getParameter(passwd); System.out.println(Password: + passwd); String pwd = , str = ; int level = -1, ind = -1; try { Connection conn = null; Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); conn=DriverManager.getConnection(jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb); Statement stmt = conn.createStatement(); String query = SELECT * FROM user where name = ' + userid + '; ResultSet st = stmt.executeQuery(query); if (st.next()) { pwd = st.getString(password); level = st.getInt(level); System.err.println(Query result=+userid+/+pwd+/+level); } else { ind = -2; System.out.println(No user with name + userid + available in the database); } if (stmt != null) { stmt.close(); } if (conn != null) { conn.close(); } } catch (Exception e) { e.printStackTrace(); } if(pwd.equals(passwd)) { ind = level; } // else ind = -1; System.out.println(Ind - + ind); % script language=JavaScript type=text/JavaScript var ind = %= ind % function loadHtml() { //alert(in loadHtml()); if(ind == -2) { alert(Not a valid user); location.href = login.jsp; return; } if (ind == -1) { alert(Incorrect password); location.href = login.jsp; return; } else { //alert(Correct password); location.href = Second_Page.html; return; } } /script /head body onload=javascript:loadHtml() !-- User Name : %= userid %br Password : %= passwd % -- /body /html --- code ends here --- It works. But is it the right way to do? Pls advice. --- Antony Paul [EMAIL PROTECTED] wrote: By default server.xml contains have a GlobalNamingResources. You have to add your resources in there. rgds Antony Paul On Mon, 21 Feb 2005 19:56:23 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: As just moved the GlobalNamingResources inside the main server in my server.xml residing in TOMCAT_HOME/conf directory. When i restart tomcat 5.5.7 it's throwing up following exception. INFO: Starting Servlet Engine:
Re: Name jdbc is not bound in this Context error
Yes i read and did as per the document. When it didn't work, i followed the suggetions given to many users in the mailing lists in the internet and now i guess i messed up. Actually in the error, it says, no suitable driver found. I'm using Ms Access as it's free. Do we have any free driver available in the form of jar to use in place of JDBC-ODBC bridge driver? Or it's not required if configuration is correct. Pls let me know. I've pasted all relevant code in my first mail itself. If time permits, any of you can try give me the solution. It'll be a great help. I've integrated tomcat 5.5.7 with apache 2. Does this has any impact on the above. --- Antony Paul [EMAIL PROTECTED] wrote: If you followed the tomcat docs you will have no problem in DBCP getting to work. Going for Globalnamingresources is needed if you need to access it will all applications. Try to configure it as per the doc in following URL. http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html follow MySQL config. And no need to put commons*.jar in commons/lib as TC by default comes with it. rgds Antony Paul On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: I tried without GlobalNamingResources. No luck. When googled, i found that if we include GlobalNamingResource tag, then it will be available in all web context. After spending enough time on that, now i coded all database related stuff in JSP in the way we do in stand alone application. I mean - Coding like this in jspo itself. code -- %@ page contentType=text/html import=java.sql.*% html headtitlesimmPlan - simple material planning system/title script language=JavaScript src=/js/default.js/script % String userid = request.getParameter(userid); String passwd = request.getParameter(passwd); System.out.println(Password: + passwd); String pwd = , str = ; int level = -1, ind = -1; try { Connection conn = null; Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); conn=DriverManager.getConnection(jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb); Statement stmt = conn.createStatement(); String query = SELECT * FROM user where name = ' + userid + '; ResultSet st = stmt.executeQuery(query); if (st.next()) { pwd = st.getString(password); level = st.getInt(level); System.err.println(Query result=+userid+/+pwd+/+level); } else { ind = -2; System.out.println(No user with name + userid + available in the database); } if (stmt != null) { stmt.close(); } if (conn != null) { conn.close(); } } catch (Exception e) { e.printStackTrace(); } if(pwd.equals(passwd)) { ind = level; } // else ind = -1; System.out.println(Ind - + ind); % script language=JavaScript type=text/JavaScript var ind = %= ind % function loadHtml() { //alert(in loadHtml()); if(ind == -2) { alert(Not a valid user); location.href = login.jsp; return; } if (ind == -1) { alert(Incorrect password); location.href = login.jsp; return; } else { //alert(Correct password); location.href = Second_Page.html; return; } } /script /head body onload=javascript:loadHtml() !-- User Name : %= userid %br Password : %= passwd % -- /body /html --- code ends here --- It works. But is it the right way to do? Pls advice. --- Antony Paul [EMAIL PROTECTED] wrote: By default server.xml contains have a GlobalNamingResources. You have to add your resources in there. rgds Antony Paul On Mon, 21 Feb 2005 19:56:23 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: As just moved the GlobalNamingResources inside the main server in my server.xml residing in TOMCAT_HOME/conf directory. When i restart tomcat 5.5.7 it's throwing up following exception. INFO: Starting Servlet Engine: Apache Tomcat/5.5.7 Feb 22, 2005 11:51:46 AM org.apache.catalina.realm.UserDatabaseRealm start SEVERE:
Re: Name jdbc is not bound in this Context error
I dont whether MS Access is considered as RDBMS. For serious development it is not recommended. Using ODBC have several problems. I will recommend PostgreSQL. Now it runs very well on Windows. But requires Windows 2000 or higher. You can find it at http://www.postgresql.org/ftp/binary/v8.0.1/win32/. I am using it and have no problems. I am posting my configuration that I used to set up DBCP. server.xml --- GlobalNamingResources !-- Test entry for demonstration purposes -- Environment name=simpleValue type=java.lang.Integer value=30/ !-- Editable user database that can also be used by UserDatabaseRealm to authenticate users -- Resource name=UserDatabase auth=Container type=org.apache.catalina.UserDatabase description=User database that can be updated and saved factory=org.apache.catalina.users.MemoryUserDatabaseFactory pathname=conf/tomcat-users.xml / Resource name=jdbc/db1 auth=Container type=javax.sql.DataSource factory=org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory driverClassName=org.postgresql.Driver url=jdbc:postgresql://192.168.4.248/antony maxActive=20 maxIdle=10 maxWait=-1 username=benchmark password=benchmark / /GlobalNamingResources TOMCAT_HOME/conf/context.xml --- ResourceLink global=jdbc/db1 name=jdbc/db1 type=javax.sql.DataSource/ TOMCAT_HOME/webapps/web/WEB-INF/web.xml - resource-ref res-ref-namejdbc/db1/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref Did you defined your newly created context web in server.xml or at TOMCAT_HOME\conf\Catalina\localhost\some name.xml hope it will help. rgds Antony Paul On Mon, 21 Feb 2005 22:25:59 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: Yes i read and did as per the document. When it didn't work, i followed the suggetions given to many users in the mailing lists in the internet and now i guess i messed up. Actually in the error, it says, no suitable driver found. I'm using Ms Access as it's free. Do we have any free driver available in the form of jar to use in place of JDBC-ODBC bridge driver? Or it's not required if configuration is correct. Pls let me know. I've pasted all relevant code in my first mail itself. If time permits, any of you can try give me the solution. It'll be a great help. I've integrated tomcat 5.5.7 with apache 2. Does this has any impact on the above. --- Antony Paul [EMAIL PROTECTED] wrote: If you followed the tomcat docs you will have no problem in DBCP getting to work. Going for Globalnamingresources is needed if you need to access it will all applications. Try to configure it as per the doc in following URL. http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html follow MySQL config. And no need to put commons*.jar in commons/lib as TC by default comes with it. rgds Antony Paul On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: I tried without GlobalNamingResources. No luck. When googled, i found that if we include GlobalNamingResource tag, then it will be available in all web context. After spending enough time on that, now i coded all database related stuff in JSP in the way we do in stand alone application. I mean - Coding like this in jspo itself. code -- %@ page contentType=text/html import=java.sql.*% html headtitlesimmPlan - simple material planning system/title script language=JavaScript src=/js/default.js/script % String userid = request.getParameter(userid); String passwd = request.getParameter(passwd); System.out.println(Password: + passwd); String pwd = , str = ; int level = -1, ind = -1; try { Connection conn = null; Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); conn=DriverManager.getConnection(jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb); Statement stmt = conn.createStatement(); String query = SELECT * FROM user where name = ' + userid + '; ResultSet st = stmt.executeQuery(query); if (st.next()) { pwd = st.getString(password); level = st.getInt(level); System.err.println(Query result=+userid+/+pwd+/+level); } else { ind = -2; System.out.println(No user with name + userid + available in the
Re: Name jdbc is not bound in this Context error
Thank you for the replies. Ms Access is not a relational databaase. It's just DBMS. I didn't know that PostGreSQL is a open source RDBMS system. All the sqls, table creation etc.. works similar to Oracle or any other RDBMS? I'm working on windows 2000 machine. --- Antony Paul [EMAIL PROTECTED] wrote: I dont whether MS Access is considered as RDBMS. For serious development it is not recommended. Using ODBC have several problems. I will recommend PostgreSQL. Now it runs very well on Windows. But requires Windows 2000 or higher. You can find it at http://www.postgresql.org/ftp/binary/v8.0.1/win32/. I am using it and have no problems. I am posting my configuration that I used to set up DBCP. server.xml --- GlobalNamingResources !-- Test entry for demonstration purposes -- Environment name=simpleValue type=java.lang.Integer value=30/ !-- Editable user database that can also be used by UserDatabaseRealm to authenticate users -- Resource name=UserDatabase auth=Container type=org.apache.catalina.UserDatabase description=User database that can be updated and saved factory=org.apache.catalina.users.MemoryUserDatabaseFactory pathname=conf/tomcat-users.xml / Resource name=jdbc/db1 auth=Container type=javax.sql.DataSource factory=org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory driverClassName=org.postgresql.Driver url=jdbc:postgresql://192.168.4.248/antony maxActive=20 maxIdle=10 maxWait=-1 username=benchmark password=benchmark / /GlobalNamingResources TOMCAT_HOME/conf/context.xml --- ResourceLink global=jdbc/db1 name=jdbc/db1 type=javax.sql.DataSource/ TOMCAT_HOME/webapps/web/WEB-INF/web.xml - resource-ref res-ref-namejdbc/db1/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref Did you defined your newly created context web in server.xml or at TOMCAT_HOME\conf\Catalina\localhost\some name.xml hope it will help. rgds Antony Paul On Mon, 21 Feb 2005 22:25:59 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: Yes i read and did as per the document. When it didn't work, i followed the suggetions given to many users in the mailing lists in the internet and now i guess i messed up. Actually in the error, it says, no suitable driver found. I'm using Ms Access as it's free. Do we have any free driver available in the form of jar to use in place of JDBC-ODBC bridge driver? Or it's not required if configuration is correct. Pls let me know. I've pasted all relevant code in my first mail itself. If time permits, any of you can try give me the solution. It'll be a great help. I've integrated tomcat 5.5.7 with apache 2. Does this has any impact on the above. --- Antony Paul [EMAIL PROTECTED] wrote: If you followed the tomcat docs you will have no problem in DBCP getting to work. Going for Globalnamingresources is needed if you need to access it will all applications. Try to configure it as per the doc in following URL. http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html follow MySQL config. And no need to put commons*.jar in commons/lib as TC by default comes with it. rgds Antony Paul On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: I tried without GlobalNamingResources. No luck. When googled, i found that if we include GlobalNamingResource tag, then it will be available in all web context. After spending enough time on that, now i coded all database related stuff in JSP in the way we do in stand alone application. I mean - Coding like this in jspo itself. code -- %@ page contentType=text/html import=java.sql.*% html headtitlesimmPlan - simple material planning system/title script language=JavaScript src=/js/default.js/script % String userid = request.getParameter(userid); String passwd = request.getParameter(passwd); System.out.println(Password: + passwd); String pwd = , str = ; int level = -1, ind = -1; try { Connection conn = null; Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); conn=DriverManager.getConnection(jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=C:/tomcat/webapps/db1/db1.mdb); Statement stmt = conn.createStatement(); String query = SELECT * FROM user where name = ' + userid + ';
Re: Name jdbc is not bound in this Context error
Most SQL is same and it supports a subset of SQL 92 and SQL 99 standards. Every RDBMS vendor have some proprietory code which dont work in other databases. There is one RDBMS Firebird(http://firebird.sourceforge.net/). The site claims that it is more like Oracle. rgds Antony Paul On Mon, 21 Feb 2005 23:01:40 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: Thank you for the replies. Ms Access is not a relational databaase. It's just DBMS. I didn't know that PostGreSQL is a open source RDBMS system. All the sqls, table creation etc.. works similar to Oracle or any other RDBMS? I'm working on windows 2000 machine. --- Antony Paul [EMAIL PROTECTED] wrote: I dont whether MS Access is considered as RDBMS. For serious development it is not recommended. Using ODBC have several problems. I will recommend PostgreSQL. Now it runs very well on Windows. But requires Windows 2000 or higher. You can find it at http://www.postgresql.org/ftp/binary/v8.0.1/win32/. I am using it and have no problems. I am posting my configuration that I used to set up DBCP. server.xml --- GlobalNamingResources !-- Test entry for demonstration purposes -- Environment name=simpleValue type=java.lang.Integer value=30/ !-- Editable user database that can also be used by UserDatabaseRealm to authenticate users -- Resource name=UserDatabase auth=Container type=org.apache.catalina.UserDatabase description=User database that can be updated and saved factory=org.apache.catalina.users.MemoryUserDatabaseFactory pathname=conf/tomcat-users.xml / Resource name=jdbc/db1 auth=Container type=javax.sql.DataSource factory=org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory driverClassName=org.postgresql.Driver url=jdbc:postgresql://192.168.4.248/antony maxActive=20 maxIdle=10 maxWait=-1 username=benchmark password=benchmark / /GlobalNamingResources TOMCAT_HOME/conf/context.xml --- ResourceLink global=jdbc/db1 name=jdbc/db1 type=javax.sql.DataSource/ TOMCAT_HOME/webapps/web/WEB-INF/web.xml - resource-ref res-ref-namejdbc/db1/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref Did you defined your newly created context web in server.xml or at TOMCAT_HOME\conf\Catalina\localhost\some name.xml hope it will help. rgds Antony Paul On Mon, 21 Feb 2005 22:25:59 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: Yes i read and did as per the document. When it didn't work, i followed the suggetions given to many users in the mailing lists in the internet and now i guess i messed up. Actually in the error, it says, no suitable driver found. I'm using Ms Access as it's free. Do we have any free driver available in the form of jar to use in place of JDBC-ODBC bridge driver? Or it's not required if configuration is correct. Pls let me know. I've pasted all relevant code in my first mail itself. If time permits, any of you can try give me the solution. It'll be a great help. I've integrated tomcat 5.5.7 with apache 2. Does this has any impact on the above. --- Antony Paul [EMAIL PROTECTED] wrote: If you followed the tomcat docs you will have no problem in DBCP getting to work. Going for Globalnamingresources is needed if you need to access it will all applications. Try to configure it as per the doc in following URL. http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html follow MySQL config. And no need to put commons*.jar in commons/lib as TC by default comes with it. rgds Antony Paul On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: I tried without GlobalNamingResources. No luck. When googled, i found that if we include GlobalNamingResource tag, then it will be available in all web context. After spending enough time on that, now i coded all database related stuff in JSP in the way we do in stand alone application. I mean - Coding like this in jspo itself. code -- %@ page contentType=text/html import=java.sql.*% html headtitlesimmPlan - simple material planning system/title script language=JavaScript src=/js/default.js/script % String userid = request.getParameter(userid); String passwd = request.getParameter(passwd); System.out.println(Password: + passwd); String pwd = , str = ;
Re: Name jdbc is not bound in this Context error
Thanks for the replies. What do u mean by the following in ur erlier mail. Did you defined your newly created context web in server.xml or at TOMCAT_HOME\conf\Catalina\localhost\some name.xml Does it mean i need to create a new xml file in TOMCAT_HOME\conf\Catalina\localhost? What should be it's name? What should it contain? Pls let me know. I will try that. I didn't create any file there. Thanks again. hope it will help. rgds Antony Paul On Mon, 21 Feb 2005 22:25:59 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: Yes i read and did as per the document. When it didn't work, i followed the suggetions given to many users in the mailing lists in the internet and now i guess i messed up. Actually in the error, it says, no suitable driver found. I'm using Ms Access as it's free. Do we have any free driver available in the form of jar to use in place of JDBC-ODBC bridge driver? Or it's not required if configuration is correct. Pls let me know. I've pasted all relevant code in my first mail itself. If time permits, any of you can try give me the solution. It'll be a great help. I've integrated tomcat 5.5.7 with apache 2. Does this has any impact on the above. --- Antony Paul [EMAIL PROTECTED] wrote: If you followed the tomcat docs you will have no problem in DBCP getting to work. Going for Globalnamingresources is needed if you need to access it will all applications. Try to configure it as per the doc in following URL. http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html follow MySQL config. And no need to put commons*.jar in commons/lib as TC by default comes with it. rgds Antony Paul On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: I tried without GlobalNamingResources. No luck. When googled, i found that if we include GlobalNamingResource tag, then it will be available in all web context. After spending enough time on that, now i === message truncated === __ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Name jdbc is not bound in this Context error
You can name it the name of the context(web). The content should be similar to any other file there. I am giving a sample Context docBase=${catalina.home}/webapps/web antiResourceLocking=false antiJARLocking=false /Context rgds Antony Paul On Mon, 21 Feb 2005 23:18:55 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: Thanks for the replies. What do u mean by the following in ur erlier mail. Did you defined your newly created context web in server.xml or at TOMCAT_HOME\conf\Catalina\localhost\some name.xml Does it mean i need to create a new xml file in TOMCAT_HOME\conf\Catalina\localhost? What should be it's name? What should it contain? Pls let me know. I will try that. I didn't create any file there. Thanks again. hope it will help. rgds Antony Paul On Mon, 21 Feb 2005 22:25:59 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: Yes i read and did as per the document. When it didn't work, i followed the suggetions given to many users in the mailing lists in the internet and now i guess i messed up. Actually in the error, it says, no suitable driver found. I'm using Ms Access as it's free. Do we have any free driver available in the form of jar to use in place of JDBC-ODBC bridge driver? Or it's not required if configuration is correct. Pls let me know. I've pasted all relevant code in my first mail itself. If time permits, any of you can try give me the solution. It'll be a great help. I've integrated tomcat 5.5.7 with apache 2. Does this has any impact on the above. --- Antony Paul [EMAIL PROTECTED] wrote: If you followed the tomcat docs you will have no problem in DBCP getting to work. Going for Globalnamingresources is needed if you need to access it will all applications. Try to configure it as per the doc in following URL. http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html follow MySQL config. And no need to put commons*.jar in commons/lib as TC by default comes with it. rgds Antony Paul On Mon, 21 Feb 2005 21:52:13 -0800 (PST), U K Laxmi [EMAIL PROTECTED] wrote: I tried without GlobalNamingResources. No luck. When googled, i found that if we include GlobalNamingResource tag, then it will be available in all web context. After spending enough time on that, now i === message truncated === __ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Name jdbc is not bound in this Context error
I could able to get thro' JarperException. Thanks for replies. Now facing new problem. I'm getting NameNotFoundException - Name jdbc is not bound in this Context Environment what i'm using is: Apache 2, Tomcat 5.5, Netscape 7.2, MsAccess 2003 on windows 2000 machine. I integrated tomcat and apache as apache doesn't support jsps. I wrote a JSP called test-db.jsp which in turn calls java program TestSQLLoad.java. This TestSQLLoad.java performs dattabase operation, fetches the data from table and that data is displayed on Netscape thro' jsp. 1. test-db.jsp resides ina directory TOMCAT_HOME/webapps/web/JSP. Contents are as follows: %@ page contentType=text/html import=testpkg.TestSQLLoad% html head titleDB Test/title /head body % TestSQLLoad tst = new TestSQLLoad(); tst.init(); % h2Results/h2 User - %= tst.getUser() %br/ Pwd - %= tst.getPassword() %br/ Id - %= tst.getID() % /body /html 2. TestSQLLoad.java is residing in following directory. TOMCAT_HOME/webapps/web/classes/testpkg direcotry. Contents of this file are as follows: package testpkg; import javax.naming.*; import javax.sql.*; import java.sql.*; public class TestSQLLoad { String user = Not Connected; String pwd = no pwd; int id = -1; public void init() { try{ Context ctx = new InitialContext(); if(ctx == null ) { throw new Exception(Boom - No Context); } Context envCtx = (Context) ctx.lookup(java:comp/env); DataSource ds = (DataSource) envCtx.lookup(jdbc/db1); //DataSource ds = (DataSource)ctx.lookup(java:comp/env/jdbc/db1); if (ds != null) { Connection conn = ds.getConnection(); if(conn != null) { user = Got Connection +conn.toString(); Statement stmt = conn.createStatement(); String q = select name, password, id from user; ResultSet rst = stmt.executeQuery(q); if(rst.next()) { user=rst.getString(1); pwd=rst.getString(2); id = rst.getInt(3); } conn.close(); } } }catch(Exception e) { e.printStackTrace(); } } public String getUser() { return user; } public String getPassword() { return pwd; } public int getID() { return id; } } 3. I created a jar file using testpkg directory put it in TOMCAT_HOME/common/lib as well as TOMCAT_HOME/webapps/web/WEB-INF/lib directory. 4. I created MsAccess database called db1.mdb and put it in TOMCAT_HOME/WEBAPPS/WEB/db1 directory. I created a table called user with fields name, password and ID. ID is the primary key. 5. I included following in the server.xml of TOMCAT_HOME/conf directory. Context path=/db1 docBase=C:/tomcat/webapps/db1 debug=5 reloadable=true crossContext=true GlobalNamingResources Resource name=jdbc/db1 auth=Container type=javax.sql.DataSource factory=org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory driverClassName=sun.jdbc.odbc.JdbcOdbcDrive url=jdbc:odbc://localhost/db1 maxActive=20 maxIdle=10 maxWait=-1 / /GlobalNamingResources /Context 6. I included following in context.xml of TOMCAT_HOME/conf directory. ResourceLink global=jdbc/db1 name=jdbc/db1 type=javax.sql.DataSource/ 7. I included following in web.xml of TOMCAT_HOME/webapps/web/WEB-INF directory. resource-ref res-ref-namejdbc/db1/res-ref-name res-typejavax.sql.DataSource/res-type res-authContainer/res-auth /resource-ref 8. I copied commons-collections-2.1.1.jar, commons-dbcp-1.2.1.jar and commons-pool-1.2.jar into TOMCAT_HOME/common/lib directory. 9. I started apache, tomcat and then opened a browser and typed http://localhost/web/JSP/test-db.jsp. 10. I get following on the browser. Results User - Not Connected Pwd - no pwd Id - -1 11. On the tomcat window where tomcat is running i'm getting following error. javax.naming.NameNotFoundException: Name jdbc is not bound in this Context at org.apache.naming.NamingContext.lookup(NamingContext.java:769) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at org.apache.naming.factory.ResourceLinkFactory.getObjectInstance(Resou rceLinkFactory.java:96) at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source) at org.apache.naming.NamingContext.lookup(NamingContext.java:792) at org.apache.naming.NamingContext.lookup(NamingContext.java:139) at org.apache.naming.NamingContext.lookup(NamingContext.java:780) at org.apache.naming.NamingContext.lookup(NamingContext.java:152) at testpkg.TestSQLLoad.init(TestSQLLoad.java:22) at org.apache.jsp.JSP.test_002ddb_jsp._jspService(org.apache.jsp.JSP.tes t_002ddb_jsp:54) at