Connection 3 « Connection « Java Database Q&A





1. data connection model    coderanch.com

2. HELP - JDBC Connection & locking    coderanch.com

Transaction type SERIALIZABLE will lock records that have been read while a transaction is open. You specify it at the createStatement or executeQuery - I can't remember which. Or maybe it's at the connection level... Whatever. Either way, that's what it's for - to lock read records while a transaction is open so that they don't change.

3. howmany ways of getting a connection    coderanch.com

Let me throw out a couple of quick responses, and others can add details. 1) The "main" way of getting a Connection is: Class.forName(jdbc.driver.name); Connection conn = DriverManager.getConnection(dbURL, user, password); The "getConnection" method is overloaded so you can ignore the user and password if they are not required (they may be passed as part of the URL), or you can pass ...

4. Connection Problem    coderanch.com

Hi all, I am having a bit of difficulty getting a connection to my database using JDBC. I am using JDeveloper and have managed to create a connection to my database using the connection wizard. However when I attempt to create a connection in my code I get a ClassNotFoundException: oracle.jdbc.driver.OracleDriver I have installed the classes12.jar in my \jre\lib\ext directory and ...

5. connection to ms-access    coderanch.com

6. where dose code of geting connection should put?    coderanch.com

Liang, You should try to avoid code redundancy as much as possible. A third alternative is to put the common code in an action superclass which your actions all extend. The new action would extend struts' action class. A fourth alternative is to put all the data access code in a separate class. The action could instantiate this class and call ...

9. Connection with database Help    coderanch.com

I found in the readme file in the Driver the following! Setup copies the following files and directories to INSTALL_DIR/lib: mssqlserver.jar Microsoft SQL Server 2000 driver for JDBC and DataSource classes msbase.jar Classes used by the SQL Server driver msutil.jar Classes used by the SQL Server driver Installation copies the following files to INSTALL_DIR/SQLServer JTA: instjdbc.sql File for installing JTA Stored ...





10. Connection Class design    coderanch.com

I have a database that I would like to connect to on an AS400. Right now my basic design is to have a class that deals with the database, and can execute queries and store the result set (I then will have a getresult() method). Is this a good way to start out? I have begun writing the code, and can ...

11. Reuse database connection class    coderanch.com

The main method is only required as an access point for the JVM. If you are writing a class as a stand alone app, then you need a main method to run it. If your class is part of an application however, it would be called by another class. And course if you are using JSP there is no main method ...

12. Connection Objects & Scope    coderanch.com

Hi all, I'm doing the Sun JDBC tutorial and am confused on something. If I declare a Connection object outside of a try/catch block, shouldn't the connection be valid outside of the try/catch block in which it is actually initialized? I'm getting a 'variable con might not have been initialized' error. Does this mean that I have to enclose everything in ...

13. Problem: Unable to allocate a connection    coderanch.com

Hello, I was accessing ingres directly via a Java application, using jdbc-odbc. But, i sometimes get this error: failed to set isolation level: Unable to allocate a connection NOTE: I am using the Caribou Lake driver Any ideas? Thanks. -------------------------------------------------------------------------------- Posts: 11 | Registered: Feb 2004 | IP: Logged Sutham Rojanusorn greenhorn Member # 76563 posted July 10, 2004 10:13 AM ...

14. Having A DB Connection Which Remains Opened    coderanch.com

Hello All, I'm building a web application login module. Whenever a user login, the application would access the database SEVERAL times to pick up information for authentication. An average of ~60 users would use the system. I'm a bit worry about the data access portion. If I would to get and close a database connection on each login, is it better ...

15. connection    coderanch.com

SewSew (whoever that is), I managed to copy your code into a project in Eclipse 3.0, and build it all except for the line: String mrn = ((RegisterForm) form).getMrn(); which I had to hack to: String mrn = "whatever, we just need to compile it, not run it"; I had no build problems at all after that! I suggest you have ...

16. Connection Problem    coderanch.com

I have created a database DEV and its URL is: jdbc ointBase EV. I then added pbembedded.jar in CLASSPATH Suffix in JVM tab in Admin Console. I also created a JNDI entry as jdbc/dev. Then I created a table USER_SALARY in the schema PBPUBLIC. I want to use the table in my Session Bean to insert rows in this table. I ...





17. Java/SQL connection problems    coderanch.com

18. db connection problem    coderanch.com

19. performant connection management    coderanch.com

Hi folks, (or should I say Howdy) i just have th access ea few tables via JDBC and had problems with connection objects being created where not intended to. My question arising from that experience: When i open connections, what is the 'best practice'? Do i: - create and open one connection object in DBmanagement class and let it be initialized ...

20. Connection management best practices    coderanch.com

Some questions on the design of database connection classes... I've written a simple singleton connection manager. It has 2 static methods Connection getConnection() and void releaseConnection(Connection). It just has a Connection[] and an array to keep track of whether the connection exists and if it is being used or not. It fills in the array with active connections as it's asked ...

21. relinquishing database connections    coderanch.com

We have a web app whose connection pooling code is modeled on basic example stuff on the web (classes like ConnectionPool, PooledConnection, etc), and my understanding is that when we restart Tomcat, all the ODBC connections will be reset on the database side. Now, we know that our particular ODBC driver has a problem which results in them not being reset ...

22. creating database connection    coderanch.com

HI everyone, I am using Novell ExteNd. it has inbuild MySql (open source). I am trying to get connection. DriverManager.getConnection("jdbc:mysql://localhost:63306/SilverMaster50", "username", "password"); But somehow it is not working and giving me error Suitable driver not found. I would like to know is there any thing we have to set before execute like class path or something or instead of above syntax ...

23. limited connection    coderanch.com

24. Connection Issue    coderanch.com

We have an application which uses Oracle 8.1.7. We have connection pool which creates 5 connection on startup of the application. Scenario 1: Database server running. Tomcat server running. - Application works fine Scenario 2: Database server shutdown. Tomcat server running- Application Fails Scenario 3: Database server started. Tomcat server running - Application Fails Scenario 4: Database server running. Tomcat server ...

25. Calling a method on Connection interface    coderanch.com

Hi Friends, I have a small query worth mentioning in this forumn. We all know Connection (java.sql) is an interface. Then how can we call a method like close() on an interface reference. I mean where are these methods being referred from..Any1 knowing the reason for the same kindly help me... Thanks & Regards, Nischal

26. Class to handle connections    coderanch.com

A question, is it OK to pass my SQL into a DB_Bean that gets the connection and passes back the resultSet, what about closing the connection, will this happen automatically when the method returns or is this just a bad practice public ResultSet getRecords(String sql) throws NamingException, SQLException { Connection conn = null; InitialContext ic = new InitialContext(); DataSource ds = ...

27. Database connection problem    coderanch.com

I am working on a project servlet whose purpose is to receive an xml file and, based on some characteristics of the xml, perform a set of operations on an Advantage Database (not exactly my database of choice, but it's not my decision). The servlet is running on resin, and I'm connecting to the database using the Jdbc-Odbc Bridge. A little ...

28. JDBC Connection??    coderanch.com

29. connection on exit    coderanch.com

steps: 1. make a connection to sybase 2. Executing some sps 3. closing the connection. i want to know that when my JVM is shutdown after i executed some sps, is the connection still be alive or dangling [edited subject from 'hi'] [ January 06, 2005: Message edited by: Jeanne Boyarsky ]

30. Where should IP address in Connection?    coderanch.com

31. db connection question    coderanch.com

I am working with a team of people on revising a highly used web application. Connection pooling is currently being used, but the existing approach doesn't properly release the connection back to the pool. To rewrite everything to utilize a pool would be quite painful. The idea of using only one connection was brought up. No pool, just one connection that ...

32. SSL connection for postgres    coderanch.com

33. Cancel JDBC Connection when Browser Cancel    coderanch.com

Kened, Welcome to JavaRanch! There isn't any way of the server knowing that the browser cancelled the request. Two best practices: 1) Use the application server's connection pool (It sounds like you may already be doing this.) 2) Close the connection after each query. Don't rely on the user telling you when the request is done. You know when the query ...

34. Jdbc/Mysql dropped tcp connections    coderanch.com

Has anyone out there had any problems with Mysql causing dropped tcp connections? My hosting service is implying that my database connections are causing this to happen, in spite of the fact that the dropped connections only started about two weeks ago and my code has not changed since 5/10/2004. I suspect they are trying to "blow sunshine up my skirt". ...

36. Efficient database connections?    coderanch.com

I'm new to programming in Java, so please forgive what might be a dumb question. I wrote an application that makes many calls to a relational database. When I first wrote the program, I didn't take a lot of care to use code efficiently, and ended up repeating the same statements over and over throughout, making a single database connection to ...

37. JDBC connections client ports    coderanch.com

Outgoing it shouldn't matter - the application should just pick any free port. Its only on the remote server (i.e. the DB server) where it is important - since clients need to know which port the server is listening on. In your JDBC URL is is perfectly possible to define the port JDBC should try to connect to (check your driver ...

38. Tools to check for open connection    coderanch.com

39. Database Connections    coderanch.com

40. Database Connection in .jar    coderanch.com

41. FoxPro connection    coderanch.com

42. Question on Best Practice for Database Connections    coderanch.com

Hi, What is the best practice when utilizing a WebSphere connection pool? Currently, a application that I am working on, opens a connection when needed and passes the object to the Data Access Object which then closes the connection when it is finished with it. Would it be better to open ONE connection and store it in a session, that way ...

43. connection refused    coderanch.com

44. Database connection problem    coderanch.com

45. connection problem    coderanch.com

Why not implementing your connection pool as a queue. The real connection pool should have some properties like, - shrink - extend Now, how are you getting the connection from Map? By passing the connection object as a key? It means you already have the connection, you are not getting it from Map, right? So, what are you getting from the ...

46. how to check no of connection    coderanch.com

47. Connection to the database    coderanch.com

Hi All, I need a help in connecting to the database (MSSQL or MYSQL). I have created an "JList" using Swing, Where the list is having the Names of Different pages in that if i select a name of a page from the List means it has to open its Database Contents in a different page. I dont know how to ...

48. Problem with Jdbc connection object    coderanch.com

49. ways in doing database connection?    coderanch.com

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - ...

51. connection.setAutoCommit()    coderanch.com

52. Connection    coderanch.com

I am trying to understand connection pooling and i came across a following code As i know that we cannot create an object of Connection class by the following code: Connection con = new Connection(); // since connection class is abstract But how does it allow Connection [] con = new Connection[4]; Pls. explain ...

53. connection    coderanch.com

55. connection problem?    coderanch.com

tomcat 5.0.30 sql 4.1.12-standard I am getting the following error report after I try logging into my site, I tested to see if it was because of connection problems and its not its connecting fine, but i still get this error: HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from ...

56. jdbc connection    coderanch.com

57. Interbase drops connection    coderanch.com

Hi guys, This is a really bizzare problem. I have written a java consoloe program that transfers data from a Interbase server and puts it in a flat file. I am using JDBC to connect to the Interbase server. I open a connection to the database, run my query, get Recordset and start iterating through the recordset. For each row in ...

58. Unable to Make Connection    coderanch.com

59. Database connection - how to identify if terminated?    coderanch.com

Hi, I have a Java program that creates a java.sql.Connection to a database, inserts records, closes the connection and exits. My question is - how do I know if the connection has been terminated by some external means (e.g. DBA terminates my db session, database shuts down etc.)? Right now, my program keeps trying to insert records even if the connection ...

61. Creating a database connection class    coderanch.com

I have swing gui where in the logon screen the user enters user id and password and selects a database instance. After the LOGON button is clicked it calls a method called 'accessDB' where Connection object is used to connect to the database and do a query in a table with user information. After user is authenticated through this query a ...

62. Connection con = new Connection()    coderanch.com

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - ...

63. CallableStatement connection problem    coderanch.com

I got the following explanation from sun.com "Retrieve OUT Parameters after Results Because of limitations imposed by some DBMSs, it is recommended that for maximum portability, all of the results in a ResultSet object generated by the execution of a CallableStatement object should be retrieved before OUT parameters are retrieved. When all values have been retrieved from a result set, the ...

64. Connection validity check    coderanch.com

Guys, How to know that whether a not-null connection is a valid connection? Valid i mean, it should execute statements. I dont want to execute any statments and then get exception and then come to know that connection is NOT valid. if(conn != null){ // Is there any check to know that this connection is valid. } Thanks, Prashant

65. DataBase Connection    coderanch.com

66. Releasing Novell connection    coderanch.com

I am authenticating our Novell users using NWIDirAuthentication connection = new NWIDirAuthentication(); (within my try). I have a catch for errors but the code has no finally to close off the connection. (This is code we rehash because its worked before and I'm a student on work study). I was trying to debug a program with a fellow student when we ...

67. when to use different connections    coderanch.com

I am writing java code that accesses (selects and inserts ) data into different tables. For each table should I open a different connection? All the transactions are either simple selects (with joins) or inserts, where data from different table are picked up and then inserted. I think new connections are not required, but currently in the code I have, which ...

68. Howto: validate classpath specified by user when doing test connection    coderanch.com

Hi All, I need to do a test connection when the user has specfied username, passwros, url etc. While using this i can test the connection but can someone please tell me how can i validate the CLASSPATH also entered by the user. Can i possibly temorarily set the classpath to what user has specified and test the connection? Please help! ...

69. connection problem    coderanch.com

//better to order attributes for usae below PreparedStatement stmt = conn.prepareStatement("SELECT one, two FROM Add WHERE Product_ID = ?"); stmt.setString(1, selectFind.getText()); //start counting from ONE! ResultSet rs = stmt.executeQuery(); if(rs.next) //better than calling it without the 'if' - see below { //data should be read once once and preferably in order - read the javadoc for more info String textOne = ...

70. Connection    coderanch.com

Hi Okay here is the answer. When u say Class.forName("oracle.driver.OracleDriver"); Class.forName gets executed. it loads the class "OracleDriver". In class OracleDriver, there is a static block which gets executed as stated below public class OracleDriver { OracleDriver orDriver = null ; static { if(orDriver == null) { //loads and creates a new object if it does not exist OracleDriver orDriver = ...

71. Setting classpath to test connection to database    coderanch.com

Hi All, I need to the following: 1. Test connection to a database/datasource using the classpath specified by the user. The classpath will be an absolute path like c:\...where the jar will be located. I have the some question regarding that: a. I can't set classpath at runtime, can i? b. How can I load jars at runtime to test connection ...

72. connection object question    coderanch.com

Bear, Thanks for the reply. I am already making a connection as below: public Connection getConnection(){ // Make connection to a SQL Server 2000 database. Connection con = null; try { Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); con = DriverManager.getConnection("jdbc:microsoft:sqlserver://"+ HOST_NAME +":1433;DatabaseName="+ DB_NAME +";User="+ USER_NAME +";Password="+ PASSWORD +""); } catch (Exception e) { fail("Get Connection getConnection threw an exception: " +(e.getMessage())); } return con; } What ...

73. Using a connection class?    coderanch.com

I am creating a Java connection to a MySQL database and I have several different classes which will be utilizing that connection for various purposes. This will involve different MySQL user accounts where the user logs in to the database and performs the necessary actions. So, I guess my question is: Is there a way to create a Connection class for ...

74. how to find the connection object is commitable    coderanch.com

hi Jeanne, Thank you. I want to do a two-phase commit for a connection, (it is already provided by JTA, reinvent the wheel). I want to write a connection manager that handles N number of connection in a transaction. i want to know all the statements in all the connection object is executed fine then i want to fire the commit ...

75. how to properly handle connections    coderanch.com

Hi, I have a utility class that has 2 methods - openConnection() and closeConnection(). These methods are used by a data access class that has 5 methods. Each of the 5 methods will open a connection and close a connection, and they run one after the other as part of an initialization routine for retrieving data. My questions is: Should I ...

76. DB connections    coderanch.com

I would add that anyone who obtains a JDBC Connection in a JSP is likely to also start a transaction from that JSP. This is really poor as client applications are subject to interruptions or unexpected terminations. If you start and stop a transaction at the client level, you risk: - Consumption of network resources during waits for user actions or ...

77. Connection Object    coderanch.com

78. Starting to open the connection at the beginning of the class    coderanch.com

How come i can't place the try at the start of a new class and the code below is giving me a problem.and regarding declaring an array to store the info in the database to replace the static code at the bottom is also giving problem. public class Catalog { static String itemName,carModel,specifications,listPrice; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch (ClassNotFoundException e) { ...

79. how to get connection    coderanch.com

Websphere 4.0 and database 7.2 both on single windows XP machine. when I am establishing connection from websphere to database server,I am getting the following errors. <<< ERROR--10:13:36-- at java.lang.reflect.Method.invoke(Native Method) at javax.security.auth.login.LoginContext.invoke(LoginContext.java:595) at javax.security.auth.login.LoginContext.access$000(LoginContext.java:125) at javax.security.auth.login.LoginContext$3.run(LoginContext.java:531) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.login.LoginContext.invokeModule(LoginContext.java:528) at javax.security.auth.login.LoginContext.login(LoginContext.java:449) at com.mst.security.domain.SecurityService.login(SecurityService.java:77) at com.mst.security.servlet.SecurityController.doPost(SecurityController.java:132) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:718) at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:160) at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:287) at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:105) at ...

80. Database Connection    coderanch.com

Hi, Have a good day... we can implement connection using two ways.. 1)first, jndi - initial context 2)second , class.forname()-driver manager in these ways , which is good way..and what is the diffrence between this ? when implement jndi or driver manager... ? please clarify this. Thanks in anticipation. rgds, Nimish [ September 02, 2005: Message edited by: Nimish Patel ] ...

81. connection to database    coderanch.com

Hi, Database :7.2.0 WebSphere :4.0 OS : windows XP Database & Application server both on single machine win XP.when I deployed the application on app server I am not able to connect to database server. I am getting the following errors : 05.09.21 11:34:01:281 GMT+05:30] 6672fb1d SystemOut U Error -> [05.09.21 11:34:02:578 GMT+05:30] 6672fb1d ServletInstan X SRVE0068E: Did not realize service() ...

82. Connection over a web    coderanch.com

83. Can we preserve Connection object    coderanch.com

84. JDBC Connection configuration    coderanch.com

Thanks so much for your reply. I've decided to keep the connection open on the same session as it allows me a better control on the database server: on the as/400 the database service which listens on 8471 port, generates a new job for each new connection; that's why i keep the connection alive along the same session. Thanks again.

85. Connection is busy with results for another hstmt    coderanch.com

Hi all, i am using tomcat 4.12 and sql server 2000 in our project. i am getting Connection is busy with results for another hstmt exception. i am executing second query based on the first query result. once first query is executed then i had closed resultset and statement objects and reused result set and statement object n the second query. ...

86. database connection    coderanch.com

88. Hunting leaking connections    coderanch.com

Hi, to keep it short, a software running on WebLogic is leaking connections, so I'll need to fix this. The problem is not apparent, so it'll take a bit effort from me. I have a question about one case. Is this kind of structure any way vulnerable to leaking? I think not, but is it? import java.sql.Connection; import java.sql.PreparedStatement; public class ...

89. connection.SetAutoCommit    coderanch.com

Hi All, Please see the following code.. ------------ //con=getConnection();//Assume connection is there.. try { con.setAutoCommit(false); ... .. //Insert some rows into a table .. .. //All succeded.. no problems con.commit(); } catch (Exception e){ con.rollback(); } ------------ My questions are - 1. Does the AutoCommit property of the connection need to be set to TRUE?? before the connection is closed? 2. ...

90. Unable to create connection    coderanch.com

Hi pals,can anyone explain why this error occurs.I am posting the full stack trace.Thanks in advance root :Unable to create connection com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.io.EOFException STACKTRACE: java.io.EOFException at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1842) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2288) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2784) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622) at com.mysql.jdbc.Connection.execSQL(Connection.java:2370) at com.mysql.jdbc.Connection.setAutoCommit(Connection.java:525) at com.mportal.utils.DAOBean.getConnection(DAOBean.java:124) at com.mportal.utils.DAOBean.executeQuery(DAOBean.java:161) at com.mportal.action.LoginAction.Superlogindisp(LoginAction.java:115) at com.mportal.action.LoginAction.perform(LoginAction.java:36) at org.apache.struts.action.Action.execute(Action.java:415) ...

91. JDBC connection issues    coderanch.com

92. Connection problem - Cable disconnected    coderanch.com

Hi... I'm developing a batch software. And I have the problem, for example, if somebody removes the net cable the application notices that the connection cannot be used (does this with a test like select sysdate from dual) and keeps trying to reconnect. When the cable is plugged, it reconects (creates a new connection) and start it's work. The only problem ...

93. Software caused connection abort: recv failed    coderanch.com

Hello all, I have a Web Service that uses a datasource from my J2EE container. I had a very strange error this morning. The first error that I received was like this: java.sql.SQLException: Io exception: Software caused connection abort: recv failed at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:137) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:174) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:286) at oracle.jdbc.driver.T4CStatement.execute_for_rows(T4CStatement.java:497) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1109) at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1560) at com.evermind.sql.FilterStatement.executeUpdate(FilterStatement.java:61) at com.evermind.sql.FilterStatement.executeUpdate(FilterStatement.java:61) at com.evermind.sql.StatementBCELProxy.executeUpdate(StatementBCELProxy.java:53) After this ...

94. connection very slow    coderanch.com

hi, i have a java application and I have import some data from a csv file. These data update some field in a Access DB. For update the db I use: s.executeUpdate("UPDATE TableOrders SET WEEK = "+nweek+" WHERE Order = '"+norder+"'"); My problem is: if I run my application on my computer (P4 - 1gb RAM - OS windows xp) and ...

95. Connection Problem    coderanch.com

Hi, I am developing an application in JSP/Servlet with Oracle as database. I used a connecion pool for getting the connections. But I frequently encountered the problem "The maximum no of connections exceeds" from the oracle server. Though I took great care in closing the connection using the try-catch-finally block, still I encounter the connection problem. How to avoid this problem. ...

96. NEED FOR CONNECTION OBJECT    coderanch.com

97. jdbc connection    coderanch.com

98. why connection is a interface    coderanch.com

99. maintaining a connection    coderanch.com

100. Connection object    coderanch.com

Originally posted by Babji Reddy: close() will not make the connection eligible for GC. It just releases JDBC resources that are used by that connection. Right. To be clear for the questioner: just like elsewhere in Java, an object becomes eligible for GC when and only when there are no more references to it (we'll ignore weak references since they sort ...