CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 Try to connect to Data Base with JDBC Drivers

Print topic Send  topic

Author Message
pontos

Posts: 16
Posted: 04/19/2007, 1:41 AM

My web application don't want to connect to SQLServer database.

Maybe the problem come to JDBC drivers.

That is TomCat error :
java.lang.RuntimeException: Unable to create connection 'Connection1' to the database.
com.codecharge.db.PoolJDBCConnection.getConnection(PoolJDBCConnection.java:23)
com.codecharge.db.JDBCConnection.<init>(JDBCConnection.java:99)
com.codecharge.db.PoolJDBCConnection.<init>(PoolJDBCConnection.java:15)

I have JDBC/SqlServer driver, but I don't know where I must put it and if it was correctly declared in CodeCharge Studio.

How can I do ?
View profile  Send private message
negociant

Posts: 31
Posted: 04/19/2007, 2:03 AM

First of all Which DB do you use?

Did you set DB settings for this connection?
ProjectSettings->Server/Script->Connections->Connection1 (dbl click at the connections list)->Server(it's tab). Here is many fields:
MUST SET: Date Base, JDBC Driver, DataBaseUrl.
And if need: name, password, and date/time/boolean formats.

Did you place JDBC Drivers jar(s) to server (tomcat) classpath or specify path to it is system classpath ? If not, do it.
View profile  Send private message
pontos

Posts: 16
Posted: 04/19/2007, 2:23 AM

But I don't know how specify path
View profile  Send private message
negociant

Posts: 31
Posted: 04/19/2007, 2:33 AM

Most easy way is :
to copy
<JDBC Driver jar(s)> to <TOMCAT_HOME>/common/lib/.
This jar(s) will be available to all projects in this instance of Tomcat.
Is it good or bad is depends from current situation.

just interest : is it your firs java web project?
View profile  Send private message
pontos

Posts: 16
Posted: 04/19/2007, 2:45 AM

In web yes, but I did a java project with a SQL connexion which works very well.
View profile  Send private message
negociant

Posts: 31
Posted: 04/19/2007, 4:01 AM

Ok. So you must know that main stream in java programming with DB is using JDBC.
And must know all needed parameters for it.

BTW you don't answer which DB du you use?
View profile  Send private message
fady005


Posts: 115
Posted: 04/19/2007, 4:07 AM

Actually I have a problem too with JDBC connection... but it is different...
When I execute my page, it show the progress bar, etc... as if it is working on it but the problem is that the server stop responding...
I'm working with an Access Database and here's my code :
if (e.getPage().getParameter("edit")!=null){  
  JDBCConnection conn = JDBCConnectionFactory.getJDBCConnection("Connection1");  
  String sql = "UPDATE [m 4 nomenclature] SET [libellé identification]="+e.getPage().getParameter("edit").toString()+  
" WHERE [cd mat nm]="+  
DBTools.convertToString( DBTools.dLookUp("[cd mat nm]", "[m 4 nomenclature]", "[libellé identification]like'"+  
e.getPage().getParameter("old").toString()+"%'", "Connection1"), "Connection1", e.getPage().getCCSLocale());   
  System.out.println("************************ "+sql);  
  conn.executeUpdate(sql);  
  conn.closeConnection();  
}
Thanks for your help...
_________________
Be inventive !
View profile  Send private message
negociant

Posts: 31
Posted: 04/19/2007, 4:20 AM

1.
Which event did you use?
Take connections from JDBCConnectionFactory is not the best way.
If you do it in BeforeBuildXXX, BeforeExecuteXXX or afterExecuteXXX, you can get connection from command.
I.E. e.getCommand().getConnection().
2.
ThereIs class DBTools it's helper wor working with DB.
Perhaps it's contain neede methods.

For more detail help how exception stackTrace.
View profile  Send private message
fady005


Posts: 115
Posted: 04/19/2007, 7:06 AM

I was doing it on BeforeShow Event of the Page but as you told me I tried to do it on Before Build Select and Before Execute Select Event of the Table and changing the first line of my code by :
JDBCConnection conn = e.getCommand().getJdbcConnection();
But it doesn't change a lot... The server still stop responding...
_________________
Be inventive !
View profile  Send private message
fady005


Posts: 115
Posted: 04/23/2007, 6:04 AM

Can somebody help me please ? :-< Thanks
_________________
Be inventive !
View profile  Send private message
matheus

Posts: 386
Posted: 04/23/2007, 6:23 AM

If you use
JDBCConnection conn = e.getCommand().getJdbcConnection();

in the end you didn't need close Connection, if you close Connection your page didn't work.

conn.closeConnection(); 

Take this off. Codecharge will close your connection.
_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message
fady005


Posts: 115
Posted: 04/23/2007, 6:48 AM

I tried removing the closing line but it doesn't resolve my problem...
_________________
Be inventive !
View profile  Send private message
matheus

Posts: 386
Posted: 04/23/2007, 6:56 AM

If you get off all your block code, it works?

Maybe wasn't deadlock?
_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message
fady005


Posts: 115
Posted: 04/23/2007, 7:05 AM

Yes it work, that's what I do to continue working on something else...
Actually the deadlock is at the first line of my code...
In the server console I can see that it shows all the component of my page and it stop on the component where I've put the code...
_________________
Be inventive !
View profile  Send private message
matheus

Posts: 386
Posted: 04/23/2007, 7:13 AM

Deadlock I am meaning, in database. You wanna update a table and want to select it.
_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message
fady005


Posts: 115
Posted: 04/23/2007, 7:45 AM

I didn't understand... I don't use any SELECT in my sql query...
_________________
Be inventive !
View profile  Send private message
matheus

Posts: 386
Posted: 04/23/2007, 10:08 AM

You had a Dlookup.
_________________
Matheus Trevizan

Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br
View profile  Send private message
fady005


Posts: 115
Posted: 04/24/2007, 12:39 AM

Ah ok no, the DlookUp clause work well... I already tested it...

I tried to use this code :
  java.sql.Connection con = null;  
  java.sql.PreparedStatement pstmt = null;  
  
  try {  
    con = java.sql.DriverManager.getConnection("jdbc:default:connection");  
      String edit = e.getPage().getParameter("edit").toString();  
      String matnm = DBTools.convertToString( DBTools.dLookUp("[cd mat nm]", "[m 4 nomenclature]",   
"[libellé identification]like'"+e.getPage().getParameter("old").toString()+  
"%'", "Connection1"), "Connection1", e.getPage().getCCSLocale());  
    pstmt = con.prepareStatement("UPDATE [m 4 nomenclature] SET [libellé identification] = "  
+edit+"[cd mat nm] = "+matnm);  
    pstmt.executeUpdate();  
  }catch(Exception x){  
    System.out.println("Une exception s'est produite !" + x.getMessage());  
    System.out.println("Affichage de la pile :\n");   x.printStackTrace();  
  }finally{ if(pstmt!=null){ try{pstmt.close();}catch(java.sql.SQLException ex){ex.printStackTrace();} } }

_________________
Be inventive !
View profile  Send private message
fady005


Posts: 115
Posted: 04/24/2007, 2:19 AM

and this is the exception that I get :
  [STDOUT] DriverManager.getConnection("jdbc:default:connection")  
  [STDOUT]     trying driver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@f9104a]  
  [STDOUT] *Driver.connect (jdbc:default:connection)  
  [STDOUT]     trying driver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@19c9f16]  
  [STDOUT] *Driver.connect (jdbc:default:connection)  
  [STDOUT]     trying driver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@79ac92]  
  [STDOUT] *Driver.connect (jdbc:default:connection)  
  [STDOUT]     trying driver[className=org.hsqldb.jdbcDriver,org.hsqldb.jdbcDriver@4de3fe]  
  [STDOUT]     trying driver[className=org.hsqldb.jdbcDriver,org.hsqldb.jdbcDriver@1b35ece]  
  [STDOUT]     trying driver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@15b4b49]  
  [STDOUT] *Driver.connect (jdbc:default:connection)  
  [STDOUT] getConnection: no suitable driver  
  [STDOUT] java.sql.SQLException: No suitable driver  
	at java.sql.DriverManager.getConnection(DriverManager.java:532)  
	at java.sql.DriverManager.getConnection(DriverManager.java:193)  
	at org.apache.jsp.MaPage_jsp$MaPagePageHandler.beforeShow(MaPage_jsp.java:60)  
	at com.codecharge.components.Page.fireBeforeShowEvent(Page.java:614)  
	at org.apache.jsp.MaPage_jsp._jspService(MaPage_jsp.java:1429)  
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)  
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)  
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)  
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)  
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)  
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)  
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)  
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)  
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)  
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)  
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)  
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)  
	at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)  
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)  
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)  
	at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)  
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)  
	at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)  
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)  
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)  
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)  
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)  
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)  
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)  
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)  
	at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)  
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)  
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)  
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)  
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)  
	at java.lang.Thread.run(Thread.java:536)  
SQLException: SQLState(08001)  
  [STDOUT] Une exception s'est produite !No suitable driver  
  [STDOUT] Affichage de la pile :  
 [STDERR] java.sql.SQLException: No suitable driver  
 [STDERR] 	at java.sql.DriverManager.getConnection(DriverManager.java:532)  
 [STDERR] 	at java.sql.DriverManager.getConnection(DriverManager.java:193)  
 [STDERR] 	at org.apache.jsp.MaPage_jsp$MaPagePageHandler.beforeShow(MaPage_jsp.java:60)  
 [STDERR] 	at com.codecharge.components.Page.fireBeforeShowEvent(Page.java:614)  
 [STDERR] 	at org.apache.jsp.MaPage_jsp._jspService(MaPage_jsp.java:1429)  
 [STDERR] 	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)  
 [STDERR] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)  
 [STDERR] 	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)  
 [STDERR] 	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)  
 [STDERR] 	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)  
  [STDOUT] ResultSet.finalize sun.jdbc.odbc.JdbcOdbcResultSet@53b2c  
  [STDOUT] Statement.finalize sun.jdbc.odbc.JdbcOdbcPreparedStatement@5354a  
  [STDOUT] *PreparedStatement.close  
  [STDOUT] ResultSet.finalize sun.jdbc.odbc.JdbcOdbcResultSet@16ff2d9  
  [STDOUT] Statement.finalize sun.jdbc.odbc.JdbcOdbcPreparedStatement@1ed957d  
  [STDOUT] *PreparedStatement.close  
  [STDOUT] ResultSet.finalize sun.jdbc.odbc.JdbcOdbcResultSet@b0a518  
 [STDERR] 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)  
 [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)  
 [STDERR] 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)  
 [STDERR] 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)  
 [STDERR] 	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)  
 [STDERR] 	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)  
 [STDERR] 	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)  
 [STDERR] 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)  
 [STDERR] 	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)  
 [STDERR] 	at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)  
 [STDERR] 	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)  
 [STDERR] 	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)  
 [STDERR] 	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)  
 [STDERR] 	at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)  
 [STDERR] 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)  
 [STDERR] 	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)  
 [STDERR] 	at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)  
 [STDERR] 	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)  
 [STDERR] 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)  
 [STDERR] 	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)  
 [STDERR] 	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)  
 [STDERR] 	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)  
 [STDERR] 	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)  
 [STDERR] 	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)  
 [STDERR] 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)  
 [STDERR] 	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)  
 [STDERR] 	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)  
 [STDERR] 	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)  
 [STDERR] 	at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)  
 [STDERR] 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)  
 [STDERR] 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)  
 [STDERR] 	at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)  
 [STDERR] 	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)  
 [STDERR] 	at java.lang.Thread.run(Thread.java:536)

Also the Driver "sun.jdbc.odbc.JdbcOdbcDriver" is registred to the DeviceManager...
_________________
Be inventive !
View profile  Send private message
fady005


Posts: 115
Posted: 04/27/2007, 4:57 AM

Anyone found the problem ? Thanks
_________________
Be inventive !
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.