Connection 7 « Connection « Java Database Q&A





1. possible to establish jdbc connection with file inside jar.    forums.oracle.com

Is it possible to establish a jdbc connection within the jar. The jar I will be using has the database file. For eg. The database used is sqlite. (uses file). The file is been archieved with the jar. How to initialize a jdbc connection with the db file in the jar. Thanks in advance.

2. trouble with database connection    forums.oracle.com

i have installed mysql server 5.0 properly and can create and edit tables from the mysql command prompt, i ha ve also included the path to the jconnector (driver) in the windows path environment variable, but each time i try to conect from my program in i get a class not found exception. what could be the problem.the installed driver is ...

3. jdbc fails connection    forums.oracle.com

java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.DelegatingCallableStatement at com.acbt.ccstt.data.accessors.ConsignmentDAO.submitDeclaration(ConsignmentDAO.java:301) at com.acbt.ccstt.presentation.events.consignments.select.SubmitDeclaration.midAction(SubmitDeclaration.java:68) at com.acbt.ccstt.presentation.events.CCS21EventAction.execute(CCS21EventAction.java:36) at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Thread.java:595)

4. Check if JDBC connection is in use (Automatically)    forums.oracle.com

If this is a web application, then why are you not using the ConnectionPool provided by the Web Container/Application Server. If you do that, all you need to do is retreive a connection when you need it (i.e. at each page hit) and close it as soon as it has done its work. The Pool will take care of everything else. ...

5. Keep JDBC connection alive    forums.oracle.com

In the future JDBC related questions should be posted into the JDBC forum. Taking the time to ensure your question is posted into the right forum increases your chances of getting better answers more quickly. My suggestion would be to use a Connection pool and let the connection pool handle the issue for you. Alternatively you will have to every so ...

6. Junit connection to DB issue    forums.oracle.com

7. Connection to DB over Internet    forums.oracle.com

Hey, I'm writing a program connects to a MySQL Database over the internet and uses the standard driver provided by MySQL. Now the questions I have is 1) Secure Is doing this secure? Like is the username and password that connects to the database visible and easily sniffed or is it encrypted? 2)Speed I'm using a gigaport switch but the connection ...

8. Database Connection for PSQL 8.3    forums.oracle.com

9. Java code for DB connection    forums.oracle.com

con.close(); } catch (ClassNotFoundException e){ System.err.println("Could not load JDBC driver"); System.out.println("Exception: " + e); e.printStackTrace(); } catch(SQLException ex){ System.err.println("SQLException information"); while(ex!=null) { System.err.println ("Error msg: " + ex.getMessage()); System.err.println ("SQLSTATE: " + ex.getSQLState()); System.err.println ("Error code: " + ex.getErrorCode()); ex.printStackTrace(); ex = ex.getNextException(); // For drivers that support chained exceptions } } } }





10. Database Connection design question    forums.oracle.com

@nclow - I will work on trying the Factory Pattern for this over the weekend and post when I finish to see what you think. @abillconsl - just to make sure I understand, you're saying that I just try to connect and it will cycle through the different database connection possibilities and connect when it finds the right one? If it ...

11. Database connection in JavaScript    forums.oracle.com

12. Shall most non-transactional DAOs use the same Connection?    forums.oracle.com

Hi Dears, In my application, most DAOs just do an executeQuery or executeUpdate. I think they actually can share the same connection or even the same statement! So in my application, I can simply use one connection for non-transactional DAO operations and only use other connections for transactional DAO operations. Do you think it's a good method? Thank you in advance. ...

13. how to make a database connection in java    forums.oracle.com

I would like to add another connection provider for connecting to Visual Fox Pro .DBF files. It took me a little bit to figure out so thought I could save someone else the trouble so here it is: You need this driver installed on your PC if you do not have it already:. Microsoft OLE DB Provider for Visual FoxPro [VFP ...

14. Database Connection    forums.oracle.com

Hello to Everyone, I am getting this error for establishing a connection to the database: String url = "jdbc:oracle:thin:@c:1521:orcl"; Plz give your suggestions in this regard. Thanks Io exception: The Network Adapter could not establish the connection at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:254) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:386) at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:438) at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:164) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:34) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:752) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at com.example.jdbc.JdbcHelp.getConnection(JdbcHelp.java:14) ...

15. Database Connection on Application Startup?    forums.oracle.com

Im pretty new to java and want to setup an application wide variable. I know I can use application.setAttribute(x,x) I want one time when the application starts to setup a database connection pool, not each time someone starts the application. Then throughout my code whenever I need to I can just call the variable and pull a connection from the pool. ...

16. DB Connection    forums.oracle.com

Dear All, I am trying connect the database by using this code OracleDataSource ods = new OracleDataSource(); ods.setDriverType("thin"); ods.setServerName("jdbc:oracle:thin:@srv45"); ods.setDatabaseName("PT10GUTF8.AGI.COM"); ods.setPortNumber(1521); ods.setUser("saptesta2b8"); ods.setPassword("saptesta2b8"); con = ods.getConnection(); If i test this code i am getting this exception java.sql.SQLException: Io exception: The Network Adapter could not establish the connection at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333) at oracle.jdbc.driver.OracleConnection.(OracleConnection.java:404) at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314) at java.sql.DriverManager.getConnection(DriverManager.java:512) ...





17. too many database connections open    forums.oracle.com

Hi we are using struts, hibernate, and spring in a project. when a user starts testing, the application creates connections to the database but never closes them and the number of connections keep growing as the users continue hitting different pages. we have in OpenSessionInViewFilter singleSession=false we tried to use some connection pooling, but it doesn't seem to be working. can ...

18. Java to a Database Connection    forums.oracle.com

I used your code and added a (ClassNotfoundException) "because it wouldn't let me compile without it. I also changed your line //pstmt = con.prepareStatement(sql); pstmt = conn.prepareStatement(sql); (because there was a slight typo) Then I go for a compile and run .. and I get the following ---------- Run Java ---------- GO Connection Successful Unable to connect SQL error: java.sql.SQLException: [Microsoft][ODBC ...

19. database connections    forums.oracle.com

First rule, don't do it in JSP since they are supposed to be used in the presentation layer not in the bussiness layer. Hava a servlet do that at the very least. The best you could have, is a JNDI resource which would manage connection pooling to you for free. Best Regards, MeTitus

22. Which is efficient? (DB Connection and File Handling)    forums.oracle.com

Hi, I need to download a file(CSV file of some 100-200 KB) on click of a button in JSP. The contents of the file is also displayed in the JSP (say page1.jsp)in formatted way so that user can print the details instead of download. 1st approach: before coming to page1, connect to DB(Oracle DB, using JDBC Connection pooling) and get all ...

23. informix database connection    forums.oracle.com

24. how to fix jdbc connection when SQLstate 08S01    forums.oracle.com

SQLException: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.net.SocketException MESSAGE: java.net.ConnectException: Connection timed out: connect STACKTRACE: java.net.SocketException: java.net.ConnectException: Connection timed out: conne ct at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.ja va:156) at com.mysql.jdbc.MysqlIO.(MysqlIO.java:276) at com.mysql.jdbc.Connection.createNewIO(Connection.java:2666) at com.mysql.jdbc.Connection.(Connection.java:1531) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java :266) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at Mysql.save(Mysql.java:57) at Contact.run(Contact.java:299) at Testing.main(Testing.java:21) ...

25. database connection    forums.oracle.com

Im trying to a get a connection to my database on domain server one.com Code: { try{ Class.forName("com.mysql.jdbc.Driver"); //open driver connection System.out.println("Driver indlst"); Connection forb = DriverManager.getConnection ("jdbc:mysql://[mysql.blabla.com] ","username","password"); System.out.println("Forbindelse oprettet"); stmt = forb.createStatement(); }catch (Exception e) {System.out.println("no connection to your database");} } It doent seem to work do you have any ideas of what is wrong Info: MySQL: Host: localhost ...

26. Design question for database connection in multithreaded socket-server    forums.oracle.com

Dear community, I am programming a multithreaded socket server. The server creates a new thread for each connection. The threads and several objects witch are instanced by each thread have to access database-connectivity. Therefore I implemented factory class which administer database connection in a pool. At this point I have a design question. How should I access the connections from the ...

27. connection tot database fails    forums.oracle.com

28. Help!! - if db connection is down & on again, the website doesn't work    forums.oracle.com

Hi, Could someone please help me with this? I have a website application using Tomcat as server. The problem I have is every time database connection is off and on again (we are using IBconsole), we have to re-start Tomcat. Otherwise, the website doesn't connect to the database. Could someone please tell me how to make Tomcat recognize that db connection ...

29. it might be a JDBC Connection problem, just guess.    forums.oracle.com

Just as a guess, does the name of your mysql Driver jarfile contain "-g". If so, you are using the debug version of the Driver, and that is what is causing your problem. Look through the zipfile you downloaded and find the Driver jarfile without the "-g", that is the production Driver and should solve your problem.

30. JDBC connection issue's HELP!    forums.oracle.com

31. JDBC connection question    forums.oracle.com

Inspite of setting the jar in my classpath why i am getting this error? In order to refer to a class in a different package, you need either to import the class or refer to it by a fully classified name (one that includes the package name in front of the class name). It seems you were getting that error because ...

32. Database connection Problem ?    forums.oracle.com

Hi, In my application I am calling the database connection to retrive and store the data from DB2. But sometimes randomly I am getting the exception like below. [IBM][JDBC Driver] CLI0601E Invalid statement handle or statement is closed. SQLSTATE=S1000 My connection class is singleton. when ever I need the database connection I am calling the getConnection() from Singleton class. So can ...

33. JDBC Connection    forums.oracle.com

No, I didn't, but I didn't do so on the machine that works either. I have to admit, learning to code java almost entirely in eclipse, I have never had to directly work with a classpath, so if you can point me in the direction of where to learn how that would work in this case, that would be great. Also, ...

34. establishing a connection with a database    forums.oracle.com

Hi, can you tell me in which way I can establish a connection with a database? I'm working on NetBeans 5.5 and I put a database called "Object List" in its databases editor. I established a connection in that editor, but I don't manage to call that database from the source program and work with it. I'd need the statements and ...

35. can i use single database connection in a hole java application?    forums.oracle.com

Theoretically you can. The first reply given here assumed that the answer to your question depends only on the design of your application. That is not true. It does also depend on the behaviour of the database in the background. Most databases have a time out for connections that are idle (some, like db2 on z/OS, even cancel connections, that are ...

36. database connection    forums.oracle.com

Hi All, I'm new to java and can anybody tell me how to do this ? I have two pages (page A and page B). In page page A, i have database connection( all typical JDBc driver, connect stmt etc). My problem is, when i navigate to page B, how can i use the page A database connection ? It would ...

37. jdbc connection pb    forums.oracle.com

hello Im creating a programme that deal user's calendar I have function 1 : that will search the events of one day function 2 : that will call function 1 for 7 times function 3 :that is in another class ,I call function 3 in function 1 .function 3 return the object person with all info function 1,3 has instence of ...

38. Database connections    forums.oracle.com

Hi all I am working with a web application and I am getting the following error: Error in allocating a connection. Cause: In-use connections equal max-pool-size and expired max-wait-time. Cannot allocate more connections I understand that that means that there is no connections available and that those that were available aren't being returned to the pool. Should the be anything other ...

39. JDBC Connection Problem    forums.oracle.com

Am I the only one who didn't miss out on the irony of someone offering a Commercial JDBC driver for MS Access?? Eh? There are several (commercial drivers) in fact. Mostly they provide improvements over the bridge like - some at least are pure Java so you can use them independent of the OS - they offer more functionality and features. ...

40. Best Database connection strategy.    forums.oracle.com

What my question boils down to is at what point should a connection be passes ? Should I be calling a get connection method that creates and passes a valid connection or should I be calling a get datasource method and create the connection locally ? (Bad examples but I hope they convey what I am asking) I am using connection ...

41. JDBC connection establishing    forums.oracle.com

Sorry for the above two posts when i am tried two connect with another database it is giving following error Inside get connection Metod java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153092352)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4)))) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:323) at oracle.jdbc.driver.OracleConnection.(OracleConnection.java:260) at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:172) at pooling.ConnectionClass.getConnection(ConnectionClass.java:23) While Crating Connection objectjava.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153092352)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4)))) at pooling.ConnectionClass.main(ConnectionClass.java:42) if i connect from ...

42. JDBC Connection establishing    forums.oracle.com

} public Connection getConnection() { Connection connection=null; try { System.out.println("Inside get connection Metod"); try{ Class.forName ("oracle.jdbc.driver.OracleDriver"); } catch(Exception ex){ System.out.println("Cannot find database driver"+ex); } String strDatabaseURL ="jdbc:oracle:thin:@10.152.67.36:1521:******" ; String strUserName = "rmasupp1"; String strPassword = "Infosys"; connection =(Connection) DriverManager.getConnection(strDatabaseURL, strUserName, strPassword); System.out.println("after establishing connection"+connection); } catch(Exception E) { System.out.println("Exception Inside get Connection"+E); } return connection; } public long getRecordCount(Connection con) { ...

43. Database Connection    forums.oracle.com

45. Problem with Login Control and Database Connection , please help    forums.oracle.com

//Connection conn = DriverManager.getConnection("jdbc:odbc:myOracle"); Connection conn = DriverManager.getConnection(cs,user,pass); Statement stmt = conn.createStatement(); String query = "SELECT * FROM members"; ResultSet rs = stmt.executeQuery(query); // ResultSet rs = stmt.executeQuery("SELECT * FROM members WHERE member_id = 'M0001'"); while(rs.next()) { String s = rs.getString("member_id"); System.out.println("\n Member ID. : " + s); } System.out.println("\nOracle at 255.255.255.255 is working!"); } catch(SQLException e) { System.out.println("\n\nException Occured " ...

46. Db connection monitor    forums.oracle.com

47. JDBC with PostgreeSQL connection problem    forums.oracle.com

I have a very simple code just for testing a connection with JDBC using PostgreeSQL. I have a "postgresql-9.0-801.jdbc4.jar" as a library in my project. The problem is when I test the connection it came into an error like this: org.postgresql.util.PSQLException: The connection attempt failed. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:150) at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66) at org.postgresql.jdbc2.AbstractJdbc2Connection.(AbstractJdbc2Connection.java:125) at org.postgresql.jdbc3.AbstractJdbc3Connection.(AbstractJdbc3Connection.java:30) at org.postgresql.jdbc3g.AbstractJdbc3gConnection.(AbstractJdbc3gConnection.java:22) at org.postgresql.jdbc4.AbstractJdbc4Connection.(AbstractJdbc4Connection.java:30) at org.postgresql.jdbc4.Jdbc4Connection.(Jdbc4Connection.java:24) at org.postgresql.Driver.makeConnection(Driver.java:393) ...

48. Application logs show 3 connections, yet JDBC logs show 5 connection    forums.oracle.com

Hi, I am seeing a strange problem with our application code. We are investigating as to why connections are remaining open on our database from our application. Our JDBC driver is DB2, and we are using a DriverManagerDataSource to manage connections (I'm aware we should be using a connection pool, but that is a separate issue here). When I look at ...