Win a copy of Spring in Action (5th edition) this week in the Spring forum!

Muhammad Yasir Ch

Greenhorn
+ Follow
since Oct 05, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Muhammad Yasir Ch

I am using struts 2 and jQuery datable tabletools feature to save multiple rows in database. Currently I am able to able to select multiple rows but don't know how to send those rows to struts2 action class. Kindly guide me to resolve the issue.
5 years ago
Thanks everyone for your comments, at last the issue has been resolved.

The issue is that I used PreparedStatement.executeUpdate(sql), instead of PreparedStatement.executeUpdate(). As PreparedStatement.executeUpdate(sql) will contain query having question marks.
Following is the stack trace of exception.

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?,?,?,?,?)' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2812)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1811)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1725)
at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:228)
at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:228)
at edu.vu.mobiquiz.users.UsersManagementDao.insertUser(UsersManagementDao.java:28)
at edu.vu.mobiquiz.users.UsersManagementAction.insert(UsersManagementAction.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:161)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
Spaces has been added in the insert statement like below and the result is same having exception.

INSERT INTO users(user_id, users_name, password, role, user_status) VALUES ('mal758','1','1','ADMINISTRATOR','Blocked')

And this insert statement works fine in MySQL command line, by using statement object and also by setting this insert query in Prepared Statement object by appending query like below.

I am inserting data into MySQL database table named users using object of Prepared-statement but it gives me following error.
Same insert statement is executing fine in MySQL command prompt and by using Statement object.



-- output on console

insertUser statement => com.mysql.jdbc.JDBC4PreparedStatement@19aae6a: INSERT INTO users(user_id, users_name, password, role, user_status)VALUES('99999','','12','ADMINISTRATOR','Blocked');
SQLException occured. getErrorCode=> 1064
SQLException occured. getCause=> 42000
SQLException occured. getCause=> null
SQLException occured. getMessage=> You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?,?,?,?,?)' at line 1


Following is the structure of table and output after executing above query.

mysql> describe users;
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| user_id | varchar(20) | NO | PRI | NULL | |
| users_name | varchar(45) | YES | | NULL | |
| password | varchar(20) | YES | | NULL | |
| role | varchar(20) | YES | | NULL | |
| user_status | varchar(20) | YES | MUL | NULL | |
+-------------+-------------+------+-----+---------+-------+
5 rows in set (0.07 sec)

mysql> INSERT INTO users(user_id, users_name, password, role, user_status)VALUES
('99999','','12','ADMINISTRATOR','Blocked');
Query OK, 1 row affected (0.09 sec)

mysql>

Kindly guide me to resolve the issue.

Best regards,
Muhammad Yasir
I like to know the performance comparison w.r.t memory between following code snippets. According to my knowledge the first code snippet will consume more memory as compared to second one.

Code1
for (long l = 0; l <= 1000000; l++) {
ArrayList<myBean> arrBeanList = getBeanList();
}

Code2
ArrayList<myBean> arrBeanList = null;
for (long l = 0; l <= 1000000; l++) {
arrBeanList = getBeanList();
}
Is it possible to support multiple languages through tomcat?

As I only required to store input values from different languages like Chineese, Spanish, Russian, German etc by using JSP. I add following line in Catalina.bat file but it doesnot works.



Following text is provided as input, but different values was stored in database.
您好

Kindly guid me to resolve the issue.

Regards,
Muhammad Yasir
6 years ago
We can parse it and do it in our own style, but it seems that Prepared statement has limitation in this case.
Can anyone use IN clause of query with preparedStatement like below?

SELECT col FROM table WHERE col_id IN ('x', 'y', 'z');
SELECT col FROM table WHERE col_id IN (?);

I am unable to use it.
Go through K&B book multiple times, and then in last week alot of mock exams.
7 years ago
Today I passed the SCJP exam by scoring 86%. I like to thanks all java ranch forum fellows which contributed to me in this success.
7 years ago
I rescheduled my exam after contacting the prometric centre on their Asia Pacific Candidate Care Desk.
I came to know that the prometric software has been updated, and so we are facing these kind of issues. I have an exm on sunday but still pending as the prometric website was unavailable due to schedule maintenance. Please share your thoughts after the exam.
Yesterday(May-01-2011) at 7:30 PM (GMT + 5:00), I have exam of SCJP 6, but when I reached the test site for the exam the Prometric Centre Administrator inform us that the Prometric website is down due to schedule maintenance. And he provided us the ticket number which was provided by Prometric, and opens the case.

Can someone else has the experience to deal in this scenario, how much time will prometric take to resovle the ticket.

kindly guide me about the next step to take the exam.