mysqli - while connecting java with mysq using Apache Tommy DataSource its giving error java.sql.SQLSyntaxErrorException: -


i connecting java mysql using datasource , using apache tommy when perform operation throwing exception java.sql.sqlsyntaxerrorexception: user lacks privilege or object not found: one

i created context.xml.

        <context>           <resource name="jdbc/mydb" auth="container" type="javax.sql.datasource"            maxactive="50" maxidle="30" maxwait="10000"            username="root" password="root"             driverclassname="com.mysql.jdbc.driver"            url="jdbc:mysql://localhost:3306/testdb"/>                      </context> 

and created entry in web.xml

   <resource-ref>      <description>mysql datasource example</description>      <res-ref-name>jdbc/mydb</res-ref-name>      <res-type>javax.sql.datasource</res-type>      <res-auth>container</res-auth>    </resource-ref> 

and servlet file is

             try     {          context initcontext = new initialcontext();         context envcontext  = context)initcontext.lookup("java:/comp/env");         datasource ds = (datasource)envcontext.lookup("jdbc/mydb");         connection conn = ds.getconnection();         statement stmt=conn.createstatement();         resultset rs=stmt.executequery("select *from one");         system.out.println(rs.tostring());       }     catch(exception e)     {         e.printstacktrace();     } 

i not know wrong in code.

you need space in:

resultset rs=stmt.executequery("select * one"); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -