Sevlets « Connection « Java Database Q&A





1. re: cannot connect to the database    coderanch.com

Hi, You have mentioned that you are using text database file for your program, then how come you are trying to make a connectivity to a database server. what is your JdbcDriver & dbURL ?? If you are using Windpws 98 with Access data base , Are you defining DSN for your mdb files. solaiappan

2. The best way to connect\disconnect to Database    coderanch.com

Hello , I have been doing servlets programming but do not really have any great knowledge of the DataBase. Whenever my Servlets require to be connected to the Database I do it by writting it in the init() method the following: 1)Loading of the Driver and 2)Getting the connection i.e: DriverManager.registerDriver(new Oracle:jdbc.driver. OracleDriver ()); DriverManager.getConnection("jdbc racle:thin@netserv:2345:ORCL" " "," "); Is this ...

3. connecting to Access DB?    coderanch.com

4. Closing a db connection    coderanch.com

Yes, I'm curious too. I have developed just such a method, but I'm not quite sure what to do if the result set contains more elements than I want to display in my HTML table. It sounds like you are maybe dealing with the same problem?? Otherwise, you can just create the table and close the connection, no problem, right?? But ...

7. Re: Closing database connection in destroy metod()?    coderanch.com

Based on the definition of the destroy(), This method is only called once all threads within the servlet's service method have exited or after a timeout period has passed. You should see servlet destroy often when you shut down the web server. Therefore, closing database connection only in destroy method is inappropriate. Why don't you close the connection whenever you finish ...

9. open database connection    coderanch.com

Hello, I am using a number of servlets that connect to a database using another class x. The code for opening the database connection is in the constructor of class x. So everytime the servlets are loaded an instance of this class x is created and the database connection is opened. My question is how do I ensure that the resources ...





10. database connection issue    coderanch.com

11. Webappcabaret.com database connection    coderanch.com

Hi all, I was trying the examples from 13th chap of Prof Jsp 2nd edition.Its working fine.When i tried to host the voting application in webappcabaret.com i'm the getting the foll error. "java.sql.SQLException: General error: Table 'arswami.COUNTY' doesn't exist" I created the table and populated it using the SQL statements given in the book. This is the driver name "org.gjt.mm.mysql.Driver". and ...

12. JDBC Connection Exception    coderanch.com

14. How to use JNDI to connect database    coderanch.com

15. Database Connection Pooling    coderanch.com





17. JDBC connection    coderanch.com

19. db connection timeout    coderanch.com

20. connect remotely to database    coderanch.com

21. Database connection gives exception    coderanch.com

I would suggest you do the following. 1. While using tomcat, please ** do not ** edit server.xml to define your context. Define your context in .xml and place it in conf/catalina/ directory ( would be localhost in your case). 2. You **need not** define any elements in your web.xml. All resources shall be defined in .xml. The following is ...

22. DB connection on init    coderanch.com

hi i want to know if i use connection pooling where should i establish my db connection is it in init or service if i put in the init since the init is executed onely onece will give me any problems when concurrent uses login to the app or if i have 10 servlets will there any problem in the connection ...

23. Constant JDBC Connection    coderanch.com

25. jdbc connections    coderanch.com

Originally posted by satish kumar bairi: hi all, in my application i need to deal with different databases. can u suggest me which is the best way . regards, satish Its nearly impossible to design a large-scale application that works indepentently of the database being used. Sure, there are ways to make database transitions less painful, but its rare to find ...

26. where should i create the database connection    coderanch.com

Let the deployer of your application create a connection pool at the server and then you can use that from within your application.You can even have the name of the connection pool in a external property file.So that if you deploy your applcation in some other server and the name of the connection pool is something else ..then also you do ...

28. JDBC Connection    coderanch.com

It depends on what you are going to do with that connection. High performance / high load applications don't establish their connections in a servlet at all. They use connection pools which allow your servlet to access an already running connection when it needs it. If you create your connection in the init method, all requests will have to share the ...

29. database connection help    coderanch.com

Sanjit, I think that a much better approach is to let your servlet container handle DB connection pooling for you. Compared with the approach you outlined, you should see improved response times, better memory management, and you won't have to worry about where you can and cannot access your connections. You didn't specify what container you are using (Tomcat, Jetty, etc), ...

30. database connection problem    coderanch.com

hey im using a connection pool for my database access, but when i try to run my project the following error is appearing: [code] HTTP Status 404 - /Hospital_Administration_System/ type Status report message /Hospital_Administration_System/ description The requested resource (/Hospital_Administration_System/) is not available. Apache Tomcat/5.5.17 [code] is there a problem in my Database Connection Manager? thanks

31. Setting JDBC Connection object in the HttpSession?    coderanch.com

You can do some thing like this, Create a thread local connection, let your filter create the connection(or get one from the pool) and attach it with current request thread, Create a JdbcUtil which will return a connection attached with current thread upon calling getConnection(). Filter will close (may be return to pool) the connection. This way you will have one ...

32. On DB Connections, MVC2, and Sessions    coderanch.com

Hi all, I have some questions for you. I cannot specifically point out what kind of problem I am encountering in my application, but here's what's happening: - I have a web application project deployed in the Sun Glassfish Sever, the project follows the MVC2 architecture. - I am using connection pool for database connection. - I have an OracleDAOFactory with ...

33. Form-based authentication - check db connection    coderanch.com

Hey, (I am not sure if this is the section in the forum to ask the question). I have a web application that is based on form-based authentication where the userdetails and roles are stored in a database. I was wondering whether it is possible e.g. in case the database server is not started to show a message on the login ...

34. How to store the database connection as an attribute?    coderanch.com

The best thing about that example is that it uses a ServletContextListener instead of a load-on-startup servlet; the latter should not be used any more these days - it's an obsolete concept. But the example completely disregards the multithreaded nature of web apps, making it a bad example indeed. If two users access the web app simultaneously, and both end up ...

35. Database Connection Pooling initialization with dbcp    coderanch.com

Hello, I have a web app I have developed under Tomcat 6.0.18 and have added in the dbcp system. As it stands now, It wants to make connections only after the first request to the app. I want the dbcp system to initialize x number of connections on app/server startup. I know if I want to initialize things on startup I ...

36. db connection    coderanch.com

thanks for the reply. i have set up a connection pool in the app server and am looking it up in my servlet by using its JNDI name i.e Context c = new InitialContext(); Context envContext = (Context) c.lookup("java:comp/env"); (DataSource) envContext.lookup("jdbc/myDB"); I wanted to know if its a good idea to establish connection 1) only when its needed. in my case ...

37. initialising db connection    coderanch.com

hi all, have got a servlet which calls a utilities class to initialize db connection. inside the utilities class my method looks like this : public class dbUtilities { //private class variables private Connection con = null; private DataSource ds = null; public void establishDBConnection() throws SQLException, NamingException { Logger.getLogger(dbUtilities.class.getName()).log(Level.INFO, "inside establishDBConnection()"); try { if (ds == null) { ds = ...

38. preferred way to hold on database connection    coderanch.com

Howdy, first post on ranch, first of all, I tried to search on the forum (googling also), and still cannot find anything that could answer my curiosity, so here goes... what is the most prefered way to hold on to database connection (using connection pool). my current approach, everytime a request come a service class is instantiated with a connection from ...

39. Database Connection String    coderanch.com

Hi all, Firstly - I'm a newbie to Java so this post may not be in the correct place. I'm need to move a Java Servlet from using a MySQL backend to Oracle. No major problems there - although I'm searching this servlet and I can't for the of me find the current connection string in order to change it. I've ...

40. db connections to user session    coderanch.com

41. Inactive DB Connection issue    coderanch.com