CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 Server-Side Database connection

Print topic Send  topic

Author Message
Ans

Posts: 53
Posted: 05/25/2006, 2:13 AM

Hi,
I am starting a project using jsp and MS SQL Server 2000. I am using JDBC for the MS SQL Server connection.

I can access the database design connection using odbc, but when i publish the project, it gave me the follow error.

org.apache.jasper.JasperException: Unable to create connection 'spcDB' to the database.
java.lang.RuntimeException: Unable to create connection 'spcDB' to the database.
(Plus a whole lot of other information)

My driver is:
com.microsoft.jdbc.sqlserver.SQLServerDriver

and my database url is:
jdbc:microsoft:sqlserver://SGGSGPJUR1MS012:1433;DatabaseName=SPC_CPK

is any of my settings wrong? i even tried changing the server name to the IP address, but still no use.

please help! Thnaks
View profile  Send private message
Ans

Posts: 53
Posted: 05/25/2006, 7:47 PM

Quote suneelkumar:
8-)


Huh???

Anyone?
View profile  Send private message
Ans

Posts: 53
Posted: 05/28/2006, 9:28 PM

I tried using a small java program to test the jdbc connection and it worked.

import java.*;  
public class Connect{  
     private java.sql.Connection  con = null;  
     private final String url = "jdbc:microsoft:sqlserver://";  
     private final String serverName= "server1";  
     private final String portNumber = "1433";  
     private final String databaseName= "cpk";  
     private final String userName = "admin";  
     private final String password = "admin";  
     // Informs the driver to use server a side-cursor,   
     // which permits more than one active statement   
     // on a connection.  
     private final String selectMethod = "cursor";   
       
     // Constructor  
     public Connect(){}  
       
     private String getConnectionUrl(){  
          return url+serverName+":"+portNumber+";databaseName="+databaseName+";selectMethod="+selectMethod+";";  
     }  
       
     private java.sql.Connection getConnection(){  
          try{  
               Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");   
               con = java.sql.DriverManager.getConnection(getConnectionUrl(),userName,password);  
               if(con!=null) System.out.println("Connection Successful!");  
          }catch(Exception e){  
               e.printStackTrace();  
               System.out.println("Error Trace in getConnection() : " + e.getMessage());  
         }  
          return con;  
      }  
  
     /*  
          Display the driver properties, database details   
     */   
  
     public void displayDbProperties(){  
          java.sql.DatabaseMetaData dm = null;  
          java.sql.ResultSet rs = null;  
          try{  
               con= this.getConnection();  
               if(con!=null){  
                    dm = con.getMetaData();  
                    System.out.println("Driver Information");  
                    System.out.println("\tDriver Name: "+ dm.getDriverName());  
                    System.out.println("\tDriver Version: "+ dm.getDriverVersion ());  
                    System.out.println("\nDatabase Information ");  
                    System.out.println("\tDatabase Name: "+ dm.getDatabaseProductName());  
                    System.out.println("\tDatabase Version: "+ dm.getDatabaseProductVersion());  
                    System.out.println("Avalilable Catalogs ");  
                    rs = dm.getCatalogs();  
                    while(rs.next()){  
                         System.out.println("\tcatalog: "+ rs.getString(1));  
                    }   
                    rs.close();  
                    rs = null;  
                    closeConnection();  
               }else System.out.println("Error: No active Connection");  
          }catch(Exception e){  
               e.printStackTrace();  
          }  
          dm=null;  
     }       
       
     private void closeConnection(){  
          try{  
               if(con!=null)  
                    con.close();  
               con=null;  
          }catch(Exception e){  
               e.printStackTrace();  
          }  
     }  
     public static void main(String[] args) throws Exception  
       {  
          Connect myDbTest = new Connect();  
          myDbTest.displayDbProperties();  
       }  
}  

But when I try using the published page from codecharge, it does not work. I have set everything as what I have done above. I have set the classpath too. Any ideas?
View profile  Send private message
Ans

Posts: 53
Posted: 05/28/2006, 9:31 PM

Here is the long long error rept....

HTTP Status 500 -   
  
--------------------------------------------------------------------------------  
  
type Exception report  
  
message   
  
description The server encountered an internal error () that prevented it from fulfilling this request.  
  
exception   
  
org.apache.jasper.JasperException: Unable to create connection 'spcDB' to the database.  
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:207)  
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)  
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)  
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)  
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)  
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)  
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)  
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)  
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)  
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)  
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)  
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)  
	at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)  
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)  
	at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)  
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)  
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)  
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)  
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)  
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)  
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)  
	at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)  
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)  
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)  
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)  
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)  
	at java.lang.Thread.run(Unknown Source)  
  
  
root cause   
  
java.lang.RuntimeException: Unable to create connection 'spcDB' to the database.  
	at com.codecharge.db.PoolJDBCConnection.getConnection(PoolJDBCConnection.java:23)  
	at com.codecharge.db.JDBCConnection.<init>(JDBCConnection.java:85)  
	at com.codecharge.db.PoolJDBCConnection.<init>(PoolJDBCConnection.java:15)  
	at com.codecharge.db.JDBCConnectionFactory.getJDBCConnection(JDBCConnectionFactory.java:36)  
	at com.codecharge.db.JDBCConnectionFactory.getJDBCConnection(JDBCConnectionFactory.java:27)  
	at com.codecharge.GridProcessor.select(GridProcessor.java:90)  
	at com.codecharge.GridProcessor.process(GridProcessor.java:65)  
	at com.codecharge.PageProcessor.process(PageProcessor.java:28)  
	at com.codecharge.PageController.process(PageController.java:166)  
	at org.apache.jsp.NewPage1_jsp._jspService(NewPage1_jsp.java:263)  
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92)  
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)  
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162)  
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)  
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)  
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)  
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)  
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)  
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)  
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)  
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)  
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)  
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)  
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)  
	at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)  
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)  
	at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)  
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)  
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)  
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)  
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)  
	at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)  
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)  
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)  
	at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)  
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)  
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)  
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)  
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)  
	at java.lang.Thread.run(Unknown Source)  
View profile  Send private message
mrachow


Posts: 509
Posted: 05/28/2006, 11:13 PM

An idea only.
Your web pages will run under another user as your test program does.
Maybe it's a problem with your filewall?
_________________
Best regards,
Michael
View profile  Send private message
MWarloc
Posted: 05/29/2006, 2:42 AM

I can suppose
1. problem with firewall.
2. Problem with connection settings.
Which settings in ProjectSettings->Connections->spcDB->Server(tab)?
I can suppose, you set settings only in Design Tab.
3. Maybe you correct web.xml or Site.properties manually.

I think 2 and 3, because
com.codecharge.db.PoolJDBCConnection.getConnection(PoolJDBCConnection.java:23)
throrw exception only if connection pool is not created.
Ans

Posts: 53
Posted: 05/29/2006, 7:47 PM

:-/ been trying for 2 days...then....MIRACLE, it worked!!

I changed the servername on the database url to the IP instead. I think that did the trick!

Question:
1) When I set the classpath on CC, does it mean it will set the classpath for me? Cos when I run my test prog on command line, I have to set the classpath everytime I restart the comp.
View profile  Send private message
Ans

Posts: 53
Posted: 05/29/2006, 7:49 PM

btw, thanks for the help
View profile  Send private message
mrachow


Posts: 509
Posted: 05/30/2006, 12:09 AM

CC Studio will not set CLASSPATH environment variable by the given classpath property. Studio is using it for itself only to find the JDK.
But have a look if JAVA_HOME is set. I think Studio is using this first when looking for a JDK.
_________________
Best regards,
Michael
View profile  Send private message
MWarloc
Posted: 05/30/2006, 2:12 AM

CCS don't user ClassPath to find JDK.
CCS use it to compile code.

For determing JDK is using "Tools->Options->Path->Java SDK Home" or "JAVA_HOME" environment variable.
btw
for ANT is using the same scheme.

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.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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