Connection 5 « Connection « Java Database Q&A





1. Hi...jdbc..no active Connections issue...    coderanch.com

Hi, this is a pretty lengthy question (sorry!) b/c I tried to put in as much detail about my problem as I can. I am totally new to JDBC and this server stuff, so please bear with me. I am getting this error: **************** at com.devx.tradingapp.model.Connect.getConnection(Connect.java:27) at com.devx.tradingapp.model.Connect.displayDbProperties(Connect.java:44) at com.devx.tradingapp.model.Connect.main(Connect.java:80) Error Trace in getConnection() : [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing ...

2. JAVA AND DATABASE CONNECTION    coderanch.com

hello everyone, this is the only place i can get help ! Here are the details I have an html page, then i get the parameters to the servlets. Then i have a standalone class responsible for data base connection. Here is the directory structure c:\my projects\boaintegratedworkflow\src\com\system33\model\MyOracleConnection.java The source code is : package com.system33.model; import java.sql.*; public class MyOracleConnection { public ...

3. DB connection..    coderanch.com

I have an application that interfaces with a database 99% of the methods that access the database are in one class(not sure I like the design but its code I "inherited"). Each method opens its own connection and then closes the connection. If it happens to throw an exception the application gets hung. Most of the exception handling/catching was/is happening in ...

4. Problem with a bean trying to use another bean that offers db connection...[unsolved]    coderanch.com

I am developing beans for individual database tables' manipulation but thought creating redundant and unmanaged database connection in every individual bean is not wise. So, I created a ConnectionBean class that works properly and offers connection on demand. I have another bean TopicBean which needs a connection and it requests for connection from ConnectionBean and both these beans are in the ...

5. Doubt regarding Class.forName() in JDBC connection    coderanch.com

"How is it possible?" There's no problem in calling a method and ignoring a return value -- everybody does it all the time. What you're really asking is "How does calling Class.forName() make register the driver?" The answer is that by convention, JDBC driver classes contain a static initializer block which calls DriverManager.registerDriver() with an instance of its class. Static initializer ...

6. max DB connections exceeding issue    coderanch.com

Hi people, This is my first post so please be nice to me Im connecting to a MySQL database from a stand alone java application via NetBeans 5 Sometimes the application does not display data from the database & when I check the connection through NetBeans I get an error saying that the Max No. of database connections has been reached ...

7. Creating a connection to an Access Database    coderanch.com

One of the nice things about the Java API is its emphasis on portability. You don't need to write different code for the Macintosh and for MS-Windows. Similarly in the database world, you don't have to re-write your database code to work with many different databases. There is an API called 'Java DataBase Connectivity' (JDBC for short; it is mostly in ...

8. JDBC Connection    coderanch.com

9. JDBC connection in different machine    coderanch.com

HI, I'm trying to connect with oracle installed in different machine. I've oracle client installed in my machine. So i'm writing like this: import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class NewConnection { static Connection con=null; public Connection getConnection(){ try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("Jdbc :-o dbc:abcd","scott","tiger"); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { ...





10. Problem in using Database Connection for write/read    coderanch.com

Hi, I have a simple application to write/read data to/from a database. In my implementation I am using the same Connection in a program run to write as well as read data. I.e once the Connection is open, it is closed only when the program exits. The problem I am facing is that if I write some data and try to ...

11. Detect a lost of connection.    coderanch.com

Paul, That's not strictly true. Although exceptions are the best way of dealing with an occurance of a showstopping situation there are other ways to do things. In this example Nicolas wants to just check if the connection is still alive and well which can be done quickly and easily without waiting for an exception to be thrown. Have a look ...

12. Random "hangs" of JDBC connections    coderanch.com

I have a Java application connecting to a MySQL database (> 25 Gb MyISAM Engine) using JDBC mysql-connector-java-5.1.6. When I separate the database and put it on a separate server than the application it hangs in the JDBC driver after a random time and in random parts in the application. The application have a list of database connections that is used ...

13. JDBC Connection problem    coderanch.com

Hi, I am having problem in getConnection(), i written DatabaseConnection class. but it's compiling fine but while runing it's showing Exceptions. I am using NetBeans 6 and Server tomcat 6.0.16. please help to solve this problem. I added jar file that is "mysql-connector-java-5.1.6-bin.jar" i added jar file in the folder C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.16\lib I am new to coding ...

14. JDBC Connection Problem    coderanch.com

Hi friends, I written one JDBC connection class. While running it's showing Exception. i am using netbeans6.1 and jboss4.0.4 server. i added the driver also that is my-connector-java-5.1. please help me to solve this problem /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.myapp.struts; import java.sql.*; public class Database ...

15. java.net.ConnectException: Connection refused: connect    coderanch.com

Hi Ranchers, I have migrated to my vista laptop recently, And I am struggling to connect to Mysql from my Java application. The exception occurs only when I tried to connect to mysql in localhost, where as the same application can connect to mysql server running in other machines. And I have made sure my user id and passwords are correct, ...

16. JDBC Connection after DB is up    coderanch.com

I have a application running on tomcat 6 and it using the oracle as database. At some point of time my Oracle DB went down. After some time the DB is up. Now will my tomcat application keep running normally or it will have some DB connection problems? Do I need to restart my tomcat application?





18. Checking connection status    coderanch.com

Thanks for your reply When there is network failure i got exception. What i want is if the dbcp can't create connection pool then it should return null value or something instead of just throwing exception. Why i don't show stacktrace is that i know why the error occurs, it because of n/w failure only(ie purposly i disable the n/w connection). ...

19. Connection handling in large web apps    coderanch.com

Howdy I want to know what is the most efficient way to handle DB connections in a large and high traffic web app. Currently I m using a DriverManager connection to execute DB queries and updates. This *single* connection was created in my context listener and I m using it through out the application for all components to use. I still ...

20. want to skip database connection if condition is different.    coderanch.com

I have a situation here. Want to bypass database connection if caching disabled. If caching found enable, only then try to establish a database connection. One part of application should work when database is down as it doesn't require connection to database at all. While other parts should throw exception when database connection not available. the piece of code looks like ...

21. static connection    coderanch.com

Well, static will not "fix" the value of a variable. Its final you would use for this (though that doesn't stop the state of the object the variable is fixed to changing). A static variable is usually used as a shared variable. For example: public class MyDatabaseClass { public static Connection con = null; public void doStuff() { con = DriverManager.getConnection("blah") ...

22. dynamic database connection    coderanch.com

Hi i want to create one application in java.in which i want create database connection dynamically.means we can use same code for number of tables and DB..from jsp page we select table name and url so in our code work for that selected table.means generlise application..also we can select number of fileds dynamically to insert data in DB.can anyone please help ...

23. how we can create database connection dynamically.    coderanch.com

Hi sagar, I have developed a DB application, using this web application we can connect to any DB and TABLE. Just we have to type DB name and TABLE name in the properties file in key-value pair format. when our web application runs it automatically read table related information from properties file and connect to specified table. Now i want to ...

24. Too many connections    coderanch.com

Even if I use just 50 connections i get the error. I have some records in a text file which i need to process and i do so by creating different threads for the each process.So if there are 50 records, 50 threads will be created and each of them will access the DB. Why do i get the error when ...

25. How many Statements/ResultSets should be used per one Connection    coderanch.com

It's a web App and needs to query DB several times on every page, even for contents that might look static to users. so many hits are being made to the DB. It might not sound like good design, but that's how the application is designed! and I want to optimize it to better performance and resource management. For eg. the ...

26. JDBC Connection Class    coderanch.com

Hi, I was trying to create a connection class so that i can create new connections as instances of this class and to avoid 'Connection' from being public. i'm using eclipse IDE. and it shows some error in the following block of code. The error is in the instruction "Class.forName" class JdbcConnection { Connection con = null; Class.forName("com.mysql.jdbc.Driver").newInstance(); //Error is in ...

27. Handling stale connections    coderanch.com

28. Setting client ID to anonymous connection for auditing    coderanch.com

So, I've been on projects where this was done in the past so i know it's possible, but it was always somebody else who did it. I am setting up a type 4 connection to our DB2 back end and we establish connection anonymously through the pooler. We use WAS 6. How does one set the 'client ID' that database triggers ...

30. DBVISUALIZER: Connection management    coderanch.com

To be brutally frank, I'm having a hard time coming up with a suitable question, as I'm only an occasional user of an older version of the product. However, I do recall an issue that I have had with regard to managing connection definitions. * There seemed to be no way to sort or arrange the connection list entries, other than ...

32. Weak reference concept in Connection    coderanch.com

Hi all, I have the folowing code snippet private void updateTransaction(){ Connection conn = null; try { conn = getConnection(); //Do some update transactions } } catch (Exception ex) { failUpdate = true; } finally { /* try { if (conn != null) { returnConnection(conn, isConnectionOk); conn = null; } } catch (Exception dp) { } */ if(failUpdate){ try { conn ...

33. How to organize the connection through out the application process    coderanch.com

Hi, Here in my application is using the following steps for a process. - Login - Search - Update - Logout In those above steps, Login, Search, and Update actions are touching to database everytime. In each time, Im getting the Context object, I think this is a bad approach. When I hit the login, I need to get the connection ...

34. Reason for not keeping Connection instance as static    coderanch.com

It makes sense to have a getConnection to be static, because since it is a method, you can have centralized management for connection creation there, do some house-keeping if required [like, the number of connections issued, number of requests etc.... for management purpose, maybe]. But the problem with making the connection object itself static is that, then you will have only ...

35. connection validation when db is down    coderanch.com

The scenario is like this. A connection pool was configured with application server Minimum number of connections > 0 were configured. Hence they will be instantiated at server start up. I used some of the connections and closed them except one. Meanwhile DB went down. The requirement is I want to check if this is a valid connection or not with ...

36. how to make JDBC connection    coderanch.com

37. How to use the connection object defined in another class from the Main class    coderanch.com

hi, Saptarshi I have modified your code a little bit and its working. If it is that what you needed then its ok. As Balu said please avoid confusing names. code for main class import java.sql.*; /** * * @author Saptarshi */ public class main{ Statement stmt; public main() { /** * @param args the command line arguments */ try { ...

38. Connection    coderanch.com

39. The application requester cannot establish the connection    coderanch.com

Hello! Good day! My program is supposed to generate an XML and to get its contents it needs to access AS400. I'm using Eclipse as IDE. During testing, the XML is valid when I run the program in Debug Mode. Using Run As Java application, the results were inconsistent. Sometimes its valid, sometimes its not. When the XML is invalid, I ...

40. Database connection    coderanch.com

41. Failed to set Database Connection    coderanch.com

42. java.net.SocketException: No buffer space available (maximum connections reached?): JVM_Bind    coderanch.com

Hi All, May i know how to solve the error below? Does hibernate pooling help in this case? java.net.SocketException: No buffer space available (maximum connections reached?): JVM_Bind The log file from tomcat is as below: 2009-05-05 10:50:25 StandardContext[/jsp-examples]ContextListener: contextInitialized() 2009-05-05 10:50:25 StandardContext[/jsp-examples]SessionListener: contextInitialized() 2009-05-05 10:50:25 StandardContext[/servlets-examples]ContextListener: contextInitialized() 2009-05-05 10:50:25 StandardContext[/servlets-examples]SessionListener: contextInitialized() 2009-05-05 11:08:40 StandardWrapperValve[action]: Servlet.service() for servlet action threw exception org.hibernate.exception.JDBCConnectionException: ...

43. what is a stateful database connection and how to create it    coderanch.com

In a stateful connection, you rely on the fact that you will keep on using the same database connection (session) during the run of your application. Such programs typically use database session variables or temporary tables. They might set a variable in database action a: (example: user selects country "china", program stores this country in an environment variable). They can use ...

44. Best way to use connection    coderanch.com

Hello JAVA experts, I am in a process of developing a web application. I am just thinking of what would be the best way to use Connection object. I am currently adding the connection object to the user's session and using it, but I encounter some problem (Connection is busy error) when I execute a query inside a while loop of ...

45. return connection object from a function    coderanch.com

Hi, I have a function that I call with the DB info to login to the database and it returns the connection object. Can anyone see a reason to not do it this way or let me know of a better way to do it ? I just thought it would clean up my code a bit rather than having all ...

46. access a database that has limited no of connections    coderanch.com

Hi, We are having a (client) database from where the data has be fetched and displayed on a dashboard. To minimize the impact on this client database, the user account will have a limited number(say, 5) of connections allowed. But the no of user who access the dashboard will be more than 5. Can anyone please suggest what is the best ...

48. JDBC connection through a proxy    coderanch.com

Hi, I have been successfully connecting to a remotely hosted Oracle DB for some time using the code below. However, my local circumstances have changed now, in that I must now make all my connections through a proxy. I cannot figure out how to update my code to connect to the DB through the proxy so that the connection will be ...

49. javax.resource.ResourceException: Unable to get managed connection for NeoDataSource    coderanch.com

I set it like this in mssql.ds file NeoDataSource jdbc:jtds:sqlserver://MATRIX:1433//Neo_SWD_2009;instance=NEO net.sourceforge.jtds.jdbc.Driver Neo Oro12345 org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter SELECT TOP 1 name FROM sysobjects