Help - JSC to Tomcat with MySql

I built a simple test app in JSC with MySql.
Product: MySql Ver. 5.0.27-community-nt
Database name: Test
Table name: testtable
Datasource name: MySql1
Dataprovider's SQL: SELECT ALL testtable.code, testtable.name FROM testtable WHERE testtable.name LIKE ?
The page had a textfield, button, statictext and a table mapped to the dataprovider
The following code was included:
public void prerender() {
try {
String s = "";
String t = (String) textField1.getText();
if (t == null || t.equals(""))
s = "";
else
s = t;
s += "%";
staticText3.setText(s);
getSessionBean1().getTesttableRowSet().setObject(1,s);
getSessionBean1().getTesttableDataProvider().refresh();
} catch (Exception e) {error(e.toString());}
public String button1_action() {
return null;
When tested in JSC, it worked fine.
But when I exported it as a war file and deployed it in Tomcat 5.5.17 with the following settings, the statictext
displayed the selected value, but the table showed "No items found". Please help.
User: root
password: adminadmin
Connector downloaded: mysql-connector-java-5.0.4.zip
The appropriate jstl.jar and standard.jar where used by copying them from jakarta
The tomcat's server.xml used is shown below:
<?xml version="1.0" encoding="UTF-8"?>
<Server>
<Listener className="org.apache.catalina.core.AprLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
<GlobalNamingResources>
<Environment
name="simpleValue"
type="java.lang.Integer"
value="30"/>
<Resource
auth="Container"
description="User database that can be updated and saved"
name="UserDatabase"
type="org.apache.catalina.UserDatabase"
pathname="conf/tomcat-users.xml"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
<Resource
name="jdbc/Travel"
type="javax.sql.DataSource"
driverClassName="org.apache.derby.jdbc.ClientDriver"
password="travel"
maxIdle="2"
maxWait="5000"
validationQuery="select * from TRAVEL.PRODUCT"
username="travel"
url="jdbc:derby://localhost:21527/samp"
maxActive="4"/>
</GlobalNamingResources>
<Service
name="Catalina">
<Connector
port="8080"
redirectPort="8443"
minSpareThreads="25"
connectionTimeout="20000"
maxThreads="150"
maxSpareThreads="75">
</Connector>
<Connector
port="8009"
redirectPort="8443"
protocol="AJP/1.3">
</Connector>
<Engine
defaultHost="localhost"
name="Catalina">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
<Host
appBase="webapps"
name="localhost">
<Context
path="/TomTest">
</Context>
<Context
path="/TradeMeTender">
<Resource
auth="Container"
description="Creator generated DataSource Reference"
name="jdbc/Travel"
type="javax.sql.DataSource"
driverClassName="org.apache.derby.jdbc.ClientDriver"
password="travel"
maxIdle="2"
maxWait="5000"
validationQuery="SELECT * from TRAVEL.PRODUCT"
username="travel"
url="jdbc:derby://localhost:21527/sample"
maxActive="4"/>
</Context>
<Context
path="/FileUploadExample">
<EJB
home="greeting.GreeterHome"
name="GreeterEJB"
remote="greeting.Greeter"
type="Session"/>
</Context>
     <Context path="/MySqlTest" docBase="MySqlTest"
     debug="5" reloadable="true" crossContext="true">
          <Resource name="jdbc/MySql1" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="adminadmin" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/Test?autoReconnect=true"/>
     </Context>
</Host>
</Engine>
</Service>
</Server>

You could track JDBC calls and the SQL's executed by the driver at the database,
Update you datasource, DBURL with some parameters/properties to generate some info for debugging like this:
jdbc:mysql://$hostname:$port/$databasename?autoGenerateTestcaseScript=true&dumpQueriesOnException=true
Check out your deployment containers log to find out which particular SQL statement is being executed. This could help in identifying performance issues with application. That could possibly give a clue, if something is not working in your application.
For designtime JDBC calls made, this info is sent to IDE log.
Reference: http://dev.mysql.com/doc/refman/5.0/en/cj-configuration-properties.html
HTH,
Sakthi

Similar Messages

  • How use Tomcat with MySQL

    Can anybody suggest me as how to use Tomcat with MySQL server.
    Thanks in advance.
    Khiz_eng

    add the classpath to the JDBC-driver to the tomcat-
    environment (I did it in tomcat.sh)
    Then put your code accessing MySQL into a servlet....
    You can put the user-ID and the password into a session-
    object or read them in as parameters.
    The book 'core Servlets and Java Server Pages' from
    Marty Hall gave me a lot information.
    Regards
    Fredy

  • Step by step to set up tomcat with mysql

    hi i'm new to these things, well i went through the forum , there are load of info but no1 has explain how to set up (step by step) tomcat with mysql using jdbc driver ( also i'll use jsp pages to get info from the database.)
    thx alot.

    Hiya,
    Best way would be to read the README.doc that you get after the installation on the sysetm. Becuase this provided you with the exact info. pertianing to the sysetm etc that you have and also visit this website:
    http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20148108.html
    It gives u a step by step guide to set-up and some sample codes also to test etc.
    Happy Javaing, Cheers

  • Need help setting up JDBC with mySQL and Netbeans

    I've successfully got mySQL up and running and created a few simple test databases. I've been following the instructions on this website (http://www.stardeveloper.com/articles/display.html?article=2003090401&page=1 ) to get JDBC working but have had little luck.
    I've downloaded JDBC from mySQL website, extracted the mysql-connector-java-3.1.13-bin.jar file and changed the class path to :
    C:\Program Files\Java\jre1.5.0_06\lib\ext\mysql-connector-java-3.1.13-bin
    which is where I placed the .jar file.
    I then used the following code provided on stardeveloper.com to test a connection with the test database.
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class JdbcExample2 {
      public static void main(String args[]) {
        Connection con = null;
        try {
          Class.forName("com.mysql.jdbc.Driver").newInstance();
          con = DriverManager.getConnection("jdbc:mysql:///test",
            "root", "secret");
          if(!con.isClosed())
            System.out.println("Successfully connected to " +
              "MySQL server using TCP/IP...");
        } catch(Exception e) {
          System.err.println("Exception: " + e.getMessage());
        } finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
    }It compiles but when run I get the error message :
    java.lang.NoClassDefFoundError: testdatabase/JdbcExample2
    Exception in thread "main"I assume this means that my classpath isn't setup correctly but I have no idea what's up and how to correct it.
    Can someone PLEASE tell me how to setup jdbc and what I've done wrong.
    Thanks in advance :)

    Thanks for your reply. I've made some progress but I'm still having problems.
    In mySQL I created a new user called uraknai with password n0121429 and granted them access to a test database I created called pet.
    Then, in netbeans, I clicked the Runtime tab, clicked Databases and rightclicked Drivers and clicked Add Driver. I then added the driver mysql-connector-java-3.1.13-bin.jar. I then right clicked the newly added driver and selected the connect using option. I filled in the appropriate boxes clicked ok and it connected successfully.
    Then, under the project tab, I right clicked the project name, clicked properties then clicked Libraries and added the .jar file mysql-connector-java-3.1.13-bin.jar
    I then ran the following code to test the connection to the database:
    import java.sql.*;
    public class ConnectionTest {
        public ConnectionTest() {
        public static void main(String[] args)
            System.out.println("BEGIN CONNECTION TEST");
            Connection conn = null;
            try
                   String userName = "uraknai";
                   String password = "n0121429";
                   String url = "jdbc:mysql://localhost/pet";
                   Class.forName ("com.mysql.jdbc.Driver").newInstance ();
                   conn = DriverManager.getConnection (url, userName, password);
                   System.out.println ("Database connection established");
             catch (Exception e)
                   System.err.println ("Cannot connect to database server");
             finally
                   if (conn != null)
                       try
                           conn.close ();
                           System.out.println ("Database connection terminated");
                       catch (Exception e) { /* ignore close errors */ }
    }and get the message:
    java.lang.NoClassDefFoundError: math/ConnectionTest
    Exception in thread "main"
    Java Result: 1when I run the code.
    Can someone explin what I've done wrong and how to fix the problem.
    Cheers.

  • Problems with MySQL in JSC 2

    i have problem with MySQL i have a driver i added it in to servers list and i made tests with data source everythink is ok, i see tables but when i drop a table from data source on table componenet(or other) i have errors nullPointerExpection at: (here is very long list of java classes. when i click "view data" of table in data source everythink works, only in components it doesn't. Can sombody help me please. I hope you understood my problem if not i will try to explain it once again.

    i get his Exception:
    A java.lang.NullPointerException exception has occurred.
    Please report this at http://www.netbeans.org/issues.html,
    including a copy of your messages.log file as an attachment.
    The messages.log file is located in your C:\Documents and Settings\Leszczy&#324;ski\.Creator\2_0\var\log folder.
    here are details:
    java.lang.NullPointerException
         at com.mysql.jdbc.PreparedStatement.asSql(PreparedStatement.java:565)
         at com.mysql.jdbc.PreparedStatement.asSql(PreparedStatement.java:507)
         at com.mysql.jdbc.PreparedStatement.toString(PreparedStatement.java:3290)
         at java.lang.String.valueOf(String.java:2577)
         at java.lang.StringBuffer.append(StringBuffer.java:220)
         at com.mysql.jdbc.trace.Tracer.printParameters(Tracer.aj:240)
         at com.mysql.jdbc.trace.Tracer.printEntering(Tracer.aj:167)
         at com.mysql.jdbc.trace.Tracer.entry(Tracer.aj:126)
         at com.mysql.jdbc.trace.Tracer.ajc$before$com_mysql_jdbc_trace_Tracer$1$f51c62b8(Tracer.aj:45)
         at com.mysql.jdbc.Connection.registerStatement(Connection.java)
         at com.mysql.jdbc.Statement.<init>(Statement.java:190)
         at com.mysql.jdbc.PreparedStatement.<init>(PreparedStatement.java:432)
         at com.mysql.jdbc.ServerPreparedStatement.asSql(ServerPreparedStatement.java:343)
         at com.mysql.jdbc.PreparedStatement.asSql(PreparedStatement.java:507)
         at com.mysql.jdbc.ServerPreparedStatement.toString(ServerPreparedStatement.java:2306)
         at java.lang.String.valueOf(String.java:2577)
         at java.lang.StringBuffer.append(StringBuffer.java:220)
         at com.mysql.jdbc.trace.Tracer.printParameters(Tracer.aj:240)
         at com.mysql.jdbc.trace.Tracer.printEntering(Tracer.aj:167)
         at com.mysql.jdbc.trace.Tracer.entry(Tracer.aj:126)
         at com.mysql.jdbc.trace.Tracer.ajc$before$com_mysql_jdbc_trace_Tracer$1$f51c62b8(Tracer.aj:45)
         at com.mysql.jdbc.Connection.registerStatement(Connection.java)
         at com.mysql.jdbc.Statement.<init>(Statement.java:190)
         at com.mysql.jdbc.PreparedStatement.<init>(PreparedStatement.java:414)
         at com.mysql.jdbc.ServerPreparedStatement.<init>(ServerPreparedStatement.java:280)
         at com.mysql.jdbc.Connection.prepareStatement(Connection.java:4288)
         at com.mysql.jdbc.Connection.prepareStatement(Connection.java:4226)
         at com.sun.rave.sql.DesignTimeConnection.prepareStatement(DesignTimeConnection.java:187)
         at com.sun.sql.rowset.CachedRowSetXImpl.getMetaData(CachedRowSetXImpl.java:2334)
         at com.sun.data.provider.impl.CachedRowSetDataProvider.getMetaData(CachedRowSetDataProvider.java:1317)
         at com.sun.data.provider.impl.CachedRowSetDataProvider.getFieldKeys(CachedRowSetDataProvider.java:489)
         at com.sun.rave.web.ui.component.table.TableRowGroupDesignState.resetTableColumns(TableRowGroupDesignState.java:261)
         at com.sun.rave.web.ui.component.table.TableRowGroupDesignState.setDataProviderBean(TableRowGroupDesignState.java:163)
         at com.sun.rave.web.ui.component.table.TableDesignState.setDataProviderBean(TableDesignState.java:250)
         at com.sun.rave.web.ui.component.TableDesignInfo.linkBeans(TableDesignInfo.java:162)
         at com.sun.rave.insync.models.FacesModel.linkBeans(FacesModel.java:1042)
         at com.sun.rave.designer.DndHandler.processLinks(DndHandler.java:2126)
         at com.sun.rave.designer.DndHandler.importBean(DndHandler.java:880)
         at com.sun.rave.designer.DndHandler.importItem(DndHandler.java:702)
         at com.sun.rave.designer.DndHandler.importDataDelayed(DndHandler.java:376)
         at com.sun.rave.designer.DndHandler.access$000(DndHandler.java:114)
    [catch] at com.sun.rave.designer.DndHandler$1.run(DndHandler.java:298)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    yes i use JSC 2
    Is it posible that my MySQL is not working properly??
    Micz.

  • Help me out with MySQL

    I'm a beginner who's just enabled PHP and Web Server on my Mac OS X 10.5.
    But I'm stuck with MySQL. I really need some help with installing MySQL.
    It says it's pre-installed on Application > Server file, but I don't see Server File in Anywhere.
    So,I installed manually on dev.mysql.com.
    But then, I was supposed to go to usr/local file, but I don't see Local file either!
    I tried to create my own local folder and put mysql installed files in, but when I
    typed sudo chown -R mysql data/, on Terminal, it says No such file.
    Can anyone please help me install MySQL on my Mac?

    Try this

  • OC4J with MySQL please Help

    i wanna test my work with Ejb 3.0 and i want connect with MySQL
    i tested connection with MySQL database from JDeveloper
    and it successed and i created CMP from MySQL tables
    But the problem when im trying to deploy it with OC4J
    it throws an exception SQLException ( Invalid Oracle URL )
    if anybody know anything about this problem
    please help me

    thankx for help
    but it didnt work i dont know why
    i tried many way to deploy it but it stell throws exception
    << Invalid Oracle URL specifiedError Code: 17067
    >>
    this is OC4J data-sources.xml file
    <?xml version="1.0" ?>
    <data-sources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/data-sources-10_1.xsd" schema-major-version="10" schema-minor-version="1">
    <managed-data-source user="root" password="pagera" connection-pool-name="Example Connection Pool" jndi-name="jdbc/MySQLDS" name="MySQLDS" />
    <connection-pool name="Example Connection Pool">
    <connection-factory factory-class="oracle.jdbc.pool.OracleDataSource" user="root" password="pagera" url="jdbc:mysql://localhost/test" />
    </connection-pool>
    </data-sources>
    and i tried it
    <data-source class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
    name="mysqlDS" location="jdbc/mysqlCoreDS" xa-location="jdbc/xa/mysqlXADS"
    ejb-location="jdbc/mysqlDS" connection-driver="com.mysql.jdbc.Driver"
    username="root"
    password="pagera"
    url="jdbc:mysql://localhost/test"
    inactivity-timeout="30" />
    but it didnt work too
    i dont know what to do.....
    if anyone has another way pls tell me

  • Help with mySQL Connection string

    Here is hoping someone can help & once I get it down I promise I'll post all my work on this list so some other newbie can benefit.
    I'm simply trying to run a very very straightforward JDBC test with mySQL & I keep getting the "Server configuration denies access to data source" error. But before you tell me that I must simply look at what my mysql.db & mysql.user table allows - I'VE TRIED THAT. I realize that the error is probably there somewhere - but I can't see it.
    I've tried connecting with 2 different accounts - the provided "root" & a user I created "deep" to 2 different databases the provided "test" & "testdb" which I created) . Here is what mysql says about the two different databases
    mysql> select * from db;
    Host  | Db         | User |.......
    -----+------------+-------
    | %         | test    |       | ......
    | %         | test\_% |     | ........
    | localhost | testdb  | deep |........Note that "root" should have access to "test" & deep@localhost should have access to "testdb" right?
    So here are all the connection strings I have tried - all return the same error below
            Connection conn = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/test", "root", "mypass"
    //            "jdbc:mysql://localhost:3306/testdb", "deep", "mypass"
    //            "jdbc:mysql://localhost/testdb?user=deep&password=mypass"
    //            "jdbc:mysql://localhost/testdb", "deep", "mypass"
    //            "jdbc:mysql://localhost:3306/testdb?user=deep@localhost&password=mypass"
    //            "jdbc:mysql://localhost:3306/testdb?user=deep&password=mypass"
    //            "jdbc:mysql://localhost/testdb", "deep@localhost", "mypass"
    //            "jdbc:mysql:///test", "root", "mypass"
    //            "jdbc:mysql://localhost/test", "root@localhost", "mypass"
    );My Error:
    Exception in thread "main" java.sql.SQLException: Server configuration denies access to data source
            at org.gjt.mm.mysql.MysqlIO.init(MysqlIO.java:193)
            at org.gjt.mm.mysql.Connection.connectionInit(Connection.java:261)
            at org.gjt.mm.mysql.jdbc2.Connection.connectionInit(Connection.java:89)
            at org.gjt.mm.mysql.Driver.connect(Driver.java:167)
            at java.sql.DriverManager.getConnection(DriverManager.java:517)
            at java.sql.DriverManager.getConnection(DriverManager.java:199)
            at TestMySQL4.main(TestMySQL4.java:76)BTW:
    I am using MacOSX 10.1
    MySQL 3.23.42
    The driver is: mm.mysql-2.0.6.jar
    Please help!
    'deep

    hi amandeep
    well i m getting the same error message when trying to connect MYSQL using mm.jdbc driver.
    java.sql.SQLException : Server configuration denies access to data base source.
    query.jdbcDriver org.gjt.mm.mysql.Driver
    query.databaseURL jdbc:mysql://aaa.bbb.com/pluto
    query.databaseUserName samin
    query.databasePwd samin
    query.summaries true
    i hve installed mysql on server aaa.bbb.com network 1
    and trying to run application on network 2
    Thanks
    samir

  • Need help with MySQL connection error _mmServerScripts

    Trying to create insert a recordset I got the message:
    "The files from the _mmServerScripts folder are for the server model PHP-MySQL. You try to connect to a database using a different server model .Please remove this folder outside the Dreamweaver environment on both local and testing machines and try again."
    I've searched the net and have seen this message hunting people since dw8...
    I could not find a "cure".
    Things to notice:
    0 - Yes the whole thing is apache/php/mysql... just DW thinks it's not.
    1 - Both the connection and the Recordset actualy works. I have a whole site based on this connection and the recorsets I've created manualy based on it.
    2 - It does not matter if we erase or not the _mmServerScripts folder the message stands still allover.
    3 - The problem seems to show up when you split servers...
    3.1 - If I test in a WAMP environment where apache and mysql are in the same machine I can use DW to create data objects for me.
    3.2 - If I test in my real test environment which have web server and db server separated from each other then I can't use DW to create data objects, see bindings, behaviours etc... all I get is this message.... while the code itself runs fine anyway.
    Does any one already knows how to work around or fix this?
    Thanks,
    Julio

    Thanks PZ,
    Yes everything is fine with the site definition.
    everything works. I can upload, run, test all ok.
    The only thing that does not work is to insert any sort of data object through DW interface. If I declare my reordsets by hands or even If I use the ones DW created in my local test server all works fine.
    Then if I use the site definition and try to see any bindings or create a recordset or create a new connection using dw... then the messages come up and dw can't go any further in that task.
    By spli servers I mean one phisical linux server with apache/php but without mySQL + one physical Linux server with mySQL but without apache/php.
    So when I use a site definition that points either to a WAMP or LAMP i.e. when everything is in the same machine DW goes happy and does whatever it's asked to do.
    When I try that on the real mccoy environment (with the two separated servers)... It looks like DW gets confused...

  • Can' t connect Java with MySQL

    My goal is to connect Java with MySQL. I found many solutions on Internet, but I always get the same mistake:
    SQLException: No suitable driver
    SQLState: 08001
    VendorError: 0MySQL works fine alone or with php.Only thing left me to think is that the installed versions are not compatible for this mysql-connector-java-5.0.4
    I don't believe that could be a reason.
    Installed versions are:
    Apache Tomcat 5.5.20 Server
    Apache HTTP Server 2.2.4
    PHP 5.2.0
    MySQL 5.2
    jre 1.5.0_11
    jdk1.5.0_11
    Apache Tomacat JK2 connector Version: 1.2.20 File Name: mod_jk-apache-2.2.3.so
    mysql-connector-java-5.0.4
    I also set connector in class path: C:\mysql-connector-java-5.0.4;C:\mysql-connector-java-5.0.4\mysql-connector-java-5.0.4-bin.jar;C:\mysql-connector-java-5.0.4\src\com\mysql\jdbc
    For installation I used manulas from:
    http://apacheguide.org/jsp.php
    http://doc.51windows.net/mysql/?url=/MySQL/ch23s03.html
    Here is also a test code in java:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
       public class Connect
           public static void main (String[] args)
               Connection conn = null;
               try {
        conn =
           DriverManager.getConnection("jdbc:mysql://localhost/first_test" +
                                       "user=monty&password=greatsqldb");
        // Do something with the Connection
    } catch (SQLException ex) {
        // handle any errors
        System.out.println("SQLException: " + ex.getMessage());
        System.out.println("SQLState: " + ex.getSQLState());
        System.out.println("VendorError: " + ex.getErrorCode());
       }i'm desperate, please help or tell me someone who'll know the answer.
    Thank You in advance

    hey buddy .. it seems yr code is wrong .. in getconnection () method u should also specify the port ,which u r not doing ...
    the default port for MySQL is 3306 ... see below i am giving you a sample code ... its working fine .. and dont forget to put the MySQL driver jar path in to classpath and also copy the jar into common/lib folder of your tomcat ....
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class MySQLConnectionTest {
         public static void main(String[] args) {
    new MySQLConnectionTest().connTest();
    public void connTest() {
              String tableName = "portfolio"; //change as per setting
              String hostName = "10.81.9.39"; // please change for the target database ip or hostname
              String dbPort = "3306"; //change if not using the default
              String dbName = "tradingsystem"; //change as per the given DB name
              String username = "root"; //change as per setting
              String password = "password"; //change as per setting
              System.out.println("before try");
              Double data=0.0;
         Double data1=0.0;
              try {
    Class.forName("org.gjt.mm.mysql.Driver");
                   System.out.println("before driver manager");
    Connection conn = DriverManager.getConnection("jdbc:mysql://"+hostName+":"+dbPort+"/"+dbName, username, password);
    String query1 = "select * from "+tableName+" where User_id='trader1' and Stock_Type='Equity'";
    System.out.println("quesry1="+query1);
    Statement stmt = conn.createStatement();
    ResultSet rs1 = stmt.executeQuery(query1);
    while(rs1.next())
         System.out.println("hiiiiii for rs1");
         System.out.println(rs1);
         Quantity=(Integer)rs1.getObject(5);
         MarketPrice=(Double) rs1.getObject(8);
         data=Quantity*MarketPrice;
         data1+=data;
         System.out.println("data1="+data1);
         i=0;
    rs1.close();
    stmt.close();
    conn.close();
    } catch (ClassNotFoundException e) {
    e.printStackTrace(System.err);
    } catch (SQLException e) {
    e.printStackTrace(System.err);
    i hope it will work for u...
    cheers,

  • Database connectivity in struts with mysql

    Hi,
    I want to database connectivity in struts with mysql in struts-config.xml file. I have give the code in struts-config.xml file is given below...................
    <data-sources>
    <data-source key="dbname" type="org.apache.commons.dbcp.BasicDataSource" >
    <set-property property="driverClassName" value="com.mysql.jdbc.Driver" />
    <set-property property="url" value="jdbc:mysql://localhost:3306/antrowinnovation" />
    <!-- <set-property property="username" value=""/>
    <set-property property="password" value="indra" /> -->
    </data-source>
    </data-sources>
    And give the code in Action class is given below...
         int i=0;
         Connection con;
         Statement stmt;
              DataSource dataSource = (DataSource)servlet.getServletContext().getAttribute("dbname");
              System.out.println(dataSource);
         try{
              System.out.println("Database connecting....");
                   con=dataSource.getConnection();
              stmt=con.createStatement();
              System.out.println("Database connected....");
                   i=stmt.executeUpdate("insert into login values('" + username + "','" + password + "')");
                   System.out.println("Values inserted....");
                   }catch(Exception e){
                        System.out.println(e.getMessage());
                        System.out.println("Exception in try");
                        e.printStackTrace();
              return 0;
    But when i have run this then i got this Exception....
    INFO: Initialize action of type: login.LoginAction
    null
    Database connecting....
    null
    Exception in try
    java.lang.NullPointerException
         at login.LoginAction.insertUser(LoginAction.java:27)
         at login.LoginAction.execute(LoginAction.java:47)
         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:709)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:743)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
         at java.lang.Thread.run(Unknown Source)
    Plz help me..

    Read some Struts tutorial.

  • How to implement transactions in Tomcat using MySQL

    Hi,
    I am trying to find a way to implement Transactions in Tomcat 4112 using a DBCP connection pool with MySQL (connector/j 3.0.16).
    I am developing a web app using the Struts framework and have tried using JOTM for the transaction implementation. However the JOTM PreparedStatement objects do not support the getGeneratedKeys() method (which i definitely need!!!).
    I have one database with multiple datasources, but the dataase may become much larger and require multiple instances in the future so i want a solution that will scale.
    Can i use the simple JDBC connection.commit() methods? Are these robust? Or is there a simple way to use the base JTA/JTS implementation myself??
    Or is there something like JOTM that implements the full JDBC 3.0 interfaces!!
    lots of questions - sorry...
    thanks
    will crick

    I've got the same problem here.
    I want to implement a HyperlinkListener to a JLabel. (Unlike suggested above, it is only supported by JEditorPane and not JLabel)
    The goal is, that if a user clicks on a Link in a JLabel, the standard browser opens and displays that page.
    Can somebody please help?
    My ultimate goal would be to also be able to add clickable HyperLinks in ToolTip texts, but i guess that'd be even more complicated.

  • Help me i need mm.mysql driver for my sql

    i tried to connect my jsp page with mysql database but it is giving me type 4 org.gjt.mm.mysql.Driver error it says that it is not found.
    i went to mysql official site and it is saying that they have finished mm driver and now have made connector j driver for jdbc ....
    my code is this...
    <%
    Class.forName("org.gjt.mm.mysql.Driver");
    Connection myConn= DriverManager.getConnection("jdbc:mysql:///poll?user=123&password=123");
    Statement stmt=myConn.createStatement();
    ResultSet myResultSet=stmt.executeQuery("select * from pollInfo");
    if (myResultSet != null){
    while (myResultSet.next()){
    String name=myResultSet.getString ("pollname");
    String option=myResultSet.getString ("pollOption");
    String votes=myResultSet.getString ("pollvotes");%>
    <tr>
    <td><%=name%></td>
    <td><%=option%></td>
    <td><%=votes%></td>
    </tr>
    <%
    stmt.close();
    myConn.close();
    %>
    here poll is my database name and pollInfo is my table name
    user name and passwords are 123
    and when running it it give me this error.
    >>>>>>>>>>>>>>>>>>>>>
    500 Internal Server Error
    /dbquery.jsp:
    Exception thrown on line '11' from page 'C:\\Program Files\\Allaire\\JRun\\servers\\default\\default-app\\dbquery.jsp'.
    java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver [org.gjt.mm.mysql.Driver]
         at allaire.jrun.servlet.JRunServletLoader.loadClass(../servlet/JRunServletLoader.java:430)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at allaire.jrun.jsp.JSPClassLoader.loadClass(../jsp/JSPClassLoader.java:118)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Unknown Source)
         at jrun__dbquery2ejspc._jspService(jrun__dbquery2ejspc.java:44)
         at allaire.jrun.jsp.HttpJSPServlet.service(../jsp/HttpJSPServlet.java:39)
         at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:228)
         at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:196)
         at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1416)
         at allaire.jrun.session.JRunSessionService.service(../session/JRunSessionService.java:1082)
         at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:1270)
         at allaire.jrun.servlet.JRunRequestDispatcher.forward(../servlet/JRunRequestDispatcher.java:89)
         at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1552)
         at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1542)
         at allaire.jrun.servlet.JvmContext.dispatch(../servlet/JvmContext.java:364)
         at allaire.jrun.http.WebEndpoint.run(../http/WebEndpoint.java:115)
         at allaire.jrun.ThreadPool.run(../ThreadPool.java:272)
         at allaire.jrun.WorkerThread.run(../WorkerThread.java:75)
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    I am using jrun 3.1 the release of Allair ...
    now any one please help me what to do
    i willl be great ful to all of u very much thanx
    bye

    Hi,
    The driver needs to be on your classpath. So download it to (say C:\jars), what I do is rename it to mysql.jar
    Then add the C:\jars\mysql.jar to the classpath
    If you are using it with tomcat at runtime, which you are probably not, then you could also copy the jar in the tomcat\lib directory - but I have never done this.
    If you are still experiencing problems, open the jar file using winxip or the jar command and make sure that the jar build is exactly as it should be, i.e. the correct names etc.
    best
    kev

  • JSP with MYSQL on linux and windows2k

    I am using a linux box as a web server with tomcat and mysql. I aslo have a mirror on a Win2k machine running the same environment.
    I have a jsp file that uses a bean to update the database and it works on the win2k environment but not linux.
    In windows I see error messages in the tomcat console, how do I see these message on linux?
    Thank you,
    Paul.

    Did you check ALL of the files?
    There are files named "localhost_log.TODAYSDATE.txt", there are files named "catalina_log.TODAYSDATE.txt", and there's a file called "catalina.out".
    "catalina.out" appears to contain information very similar to the DOS output screen on the Windows platform.
    If those files don't have what you're looking for, then you'll have to get help from someone with more expertise than myself!

  • Error in Tomcat with Servlet

    Hi,
    I made a webapplication in JBuilder. When I run the project it runs just fine, even when I type the URL http://localhost:8080/webshop/file.shtml in explorer. Very simple.
    I installed the project war file in tomcat with the manager and tomcat made a webshop dir in web-app. This dir contains all the files needed for Tomcat to run a web-app
    I configured the web.xml, it looks like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    <servlet>
    <servlet-name>dbservlet</servlet-name>
    <servlet-class>webwinkel.DBServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>dbservlet</servlet-name>
    <url-pattern>/dbservlet</url-pattern>
    </servlet-mapping>
    </web-app>
    But the web-app doens't run online. When I try to reach the servlet I get a 404. Tomcat can't find the servlet. Am I forgetting something here, if it runs local in JBuilder shouldn't it just as easy run on a webserver?
    please help I'm desperate
    Susan

    looks like you should be pointing to the following url to get to your servlet:
    http ://localhost:8080/webshop/dbservlet
    Is this what you or your form is pointing to? Are you able to get to /file.shtml but not the servlet?

Maybe you are looking for

  • Error while transporting a Function Group!

    HI ABAPers!      We have created many function modules in a single function group. While we are trying to transport the function group we succeeded in releasing the function group from the development server to the quality system. But while we are tr

  • Is Credit Check Total the same as Experian credit tracker?

    Any difference in the two? I use Experian, but wondered if there was a better deal with CCT??

  • HT1451 music in icloud won't show in iTunes

    the extensive music collection in iCloud will not show iTunes on a properly authorized MacBook Air, I have iTunes Match on yet nothing shows.  All music shows in pods, pads and and iMac.  Any ideas ?

  • Question in cs6

    Hello, I wanted to create me a logo with cs6. But for me it did not work. First, I have the figures with paint created because I do not know how to do that in Photoshop. Then I wanted a kind of glow around making but that did work for me only in the

  • Please help me with installation...

    I want to create WebServices with Java, so I've read to install JBOSS, JWSDP and AXIS. At my pc a Tomcat 5.x-Server was running, before. So I've deinstalled this one, in order to install JBOSS, JWSDP (also including Tomcat) and AXIS. First I've insta