SQLJ in NetBeans [message #493251] |
Mon, 07 February 2011 01:55 |
knroy10
Messages: 31 Registered: July 2010 Location: kolkata
|
Member |
|
|
My Code for sqlj is something like this
import java.sql.*;
import sqlj.runtime.*;
import sqlj.runtime.ref.*;
public class Sample
{
static
{
try
{
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
}
catch (ClassNotFoundException e)
{
System.err.println("Could not load DB2 driver \n");
System.err.println(e.getMessage());
System.exit(1);
}
}
public static String getFName(int eid)
{
String url = "jdbc:db2:sample"; // database sample
String uname = "db2admin", psswrd = "db2adminn1";
String first_name=null;
try
{
Connection conn = DriverManager.getConnection(url, uname, psswrd);
DefaultContext ctx=new DefaultContext(conn);
DefaultContext.setDefaultContext(ctx);
#sql{ SELECT name into :first_name FROM staff WHERE id=:eid};
}
catch (SQLException e)
{
System.out.println("SQL Exception: ");
System.err.println(e.getMessage());
}
return first_name;
}
public static void main(String [] args)
{
System.out.println("First Name:"+getFName(80));
}
}
This code working nice in Command Prompt with Notepad.
But while trying to execute it on NetBeans IDE it is returning an error
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code
at jdbc_demo.Sample.getFName(Sample.java:33)
at jdbc_demo.Sample.main(Sample.java:47)
Java Result: 1
|
|
|