Search Results

Search found 1 results on 1 pages for 'chethu2288'.

Page 1/1 | 1 

  • facing issue when using JDBC in TomCat 7 with Struts

    - by Chethu2288
    Am developing a web application using Struts 2 where am trying to insert some values into my local MySql database. The code for connecting and accessing database works fine in console application. but its giving "java.lang.ClassNotFoundException: com.mysql.jdbc.Driver" exception when i tried the same code in Struts. Kindly help me on this. Connection conn = null; String url = "jdbc:mysql://localhost:3306/"; String dbName = "testdatabase"; String driver = "com.mysql.jdbc.Driver"; try { Class.forName(driver).newInstance(); conn = DriverManager.getConnection(url+dbName,"root","root"); Statement statement=conn.createStatement(); System.out.println("HelloWorld.execute()"); int i= statement.executeUpdate("INSERT INTO testTable VALUES('15','Lucky')"); System.out.println("res: "+i); } catch(Exception e) { System.out.println(e); //setMessage(e.getMessage()); } Awaiting your response.

    Read the article

1