• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

can anyone solve this

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the solution for the following problem..
created a form with textfields as title_of_project, names_of_students and supervisors.
whenever i try adding in any values to the title box..
the tomcat window shows an error.
that..
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Server]The name '
mechanical' is not permitted in this context. Only constants, expressions, or va
riables allowed here. Column names are not permitted.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, looks like you're sending a bad SQL query. I don't think we can help figure out your problem without seeing your database code.
[ December 19, 2003: Message edited by: Ernest Friedman-Hill ]
 
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your SQL query is probably not correct.
You must have entered "mechanical" value for any of the text field title_of_project or names_of_students or supervisors and while making a database operation it is not going in quotes probably !!! try to print your query and operate it using any dB client.
[ December 19, 2003: Message edited by: Varun Khanna ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the JDBC forum awaiting the SQL code for analysis.
bear
 
jyotsana dang
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
following is the code i wrote for inserting values into the database:
<%@ page language="java" import="java.sql.*,java.io.*" %>
<%
Connection con=null;
java.sql.Statement stmt=null;
String level="";
String project_title="";
String student_names="";
String co_supervisor="";
int year=0;
String xy=(String)session.getAttribute("y");
if(xy==null)
xy="jyotsana";
level=request.getParameter("level");

project_title=request.getParameter("project_title");
student_names=request.getParameter("student_names");
co_supervisor=request.getParameter("co_supervisor");

year=Integer.parseInt(request.getParameter("year"));

System.out.println("the value of level is:"+level);
System.out.println("the value of project_title is:"+project_title);
System.out.println("the value of student_names is:"+student_names);
System.out.println("the value of co_supervisor is:"+co_supervisor);
System.out.println("the value of year is:"+year);

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:mech_iit");
stmt=con.createStatement();
out.println("insert into project_supervised(user_login,level,project_title,student_names,co_supervisor,year) values('"+xy+"','"+level+"','"+project_title+"',"+student_names+",'"+co_supervisor+"',"+year+")");

int i=stmt.executeUpdate("insert into projects_supervised(user_login,level,project_title,student_names,co_supervisor,year) values('"+xy+"','"+level+"',"+project_title+",'"+student_names+"',"+co_supervisor+","+year+")");
System.out.println("the value of:" +i);
System.out.println("the value of:" +i);
stmt.close();

con.close();
}
catch(Exception e)
{
System.out.println(e);

}

%>

can anyone tell me where does the problem lie
Thanks
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You are missing the single quote before the student_names variable. You may want to consider using prepared statements to avoid this problem. Then you don't have to deal with the quotes.
[ December 20, 2003: Message edited by: Jeanne Boyarsky ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic