Skip to Content
0
Former Member
Oct 13, 2008 at 10:28 AM

Unable to insert values thru SQL driver

9 Views

Hi , I am having problem regarding inserting the values in SQL server,but an exception is generated.i.e..SQLException.I hav mentioned below the code,plz look over it if there is any mistake as values not being to inserted thru url statement .

If any changes to be made plz mention it.

Try

{

mgr.reportWarning("starting.....");

mgr.raiseException("ur herer",false);

String drivername="com.sap.portal.jdbc.sqlserver.SQLServerDriver";

Class.forName(drivername);

mgr.reportWarning("Driver loaded");

mgr.raiseException("Driver loaded",false);

String url="jdbc:sap:sqlserver:// ... / *:*;DatabaseName=dbname";

conn=DriverManager.getConnection(url,"username","password");

mgr.reportSuccess("you r here");

Statement stmt=conn.createStatement();

String stmt1="insert into tablename(col)".concat("values('"wdContext.currentSurveyElement().getQuestion1()"')");

//PreparedStatement pstmt=conn.prepareStatement(stmt1);

ResultSet rs=stmt.executeQuery("insert into test""(Column1)" "values('wdContext.currentSurveyElement().getQuestion1()')");

stmt.close();

conn.close();

}

Regards:

hanif