You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Maik Mrazovic <ma...@t-systems.de> on 2001/07/12 14:30:05 UTC

Problems with Database because of Datasource-Config of Struts!

Hello,

all parameters for a database of a webapplication are configured well in struts-config.xml.  There are no problems when I make a SELECT, but INSERT, DELETE or UPDATE don´t work, I don´t know why exactly.

The problem is the Connection-Object! If you use Struts-config.xml you get the Connection Object with 

java.sql.Connection myConnection = null;
try {
          javax.sql.DataSource dataSource = this.getServlet().findDataSource(null);

          if (dataSource != null)
          {
             myConnection = dataSource.getConnection();
             ... and so on.

When I aks the Object of Classname (myConnection.getClassName()) the name is apache.struts.util.GenericConnection.
With this Connectionobject are INSERT etc impossible, but why?!

If my connection-Object is developed like this:

try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection c = DriverManager.getConnection("jdbc:ODBC:V68CIMPA", "j68cimpa",
                                               "cimpa");
    
      INSERTS etc works fine!!! But that´s stupid, because I must have in every classes the database-parameter, with struts-config.xml not, it comes from .findDataSource(), in other words its better to configure the webapplication!

I hope you can help me,

best regards,

Maik Mrazovic

T - S y s t e m s 
debis Systemhaus MEB GmbH
Business Center Sales & eBusiness, R&D/VN

Erich-Herion Str. 13 
70736 Fellbach
 
(Phone) +49 711 17-40549
(Mobile) +49 170 832-5616
(email) maik.mrazovic@t-systems.de
Internet: http://www.t-systems.de