Java Basic Problems

Java Vector Numeric value and SQL Query: How to use Numeic or integer values of a vector in SQL and also how to execute them.

use Vector numeric or integer  value in sql using javaSometimes we may need to use the value of a vector mainly the integer or numeric value in SQL to execute a query . Suppose you have a vector named   studentAge which contains two numeric value for example: [10,12]. Now, if you want to use these two vectors in the SQL to for query execution then you have to write the query as given below.

String sql=”select student_name from student where student_age in (” + studentAge .toString().substring(1, studentAge.toString().lastIndexOf(“]”))+”) and student_class =”+student-class;

Just You have to use the following line

(” + studentAge.toString().substring(1, studentAge.toString().lastIndexOf(“]”))+”)

 

Numeric Value of  Vector in SQL and Execution of Query using Result Set

if (matNotInIPR.size()>0)

{

String sql=“select m.mat_no,m.type,m.specs,m.color,m.size,m.ref_no,m.uom1,s.process_name from material_view m, req_produce_mat s  where m.mat_no=s.mat_no and s.mat_no in (”  +matNotInIPR.toString().substring(1, matNotInIPR.toString().lastIndexOf(“]”))+ “) and s.item_no =”+style_id;

ResultSet rs2=st1.executeQuery(sql);

while(rs2.next()){

Vector row1=new Vector();

row1.add(rs2.getString(“process_name”));

row1.add(rs2.getInt(“mat_no”)+””);

row1.add(rs2.getString(“type”));

row1.add(rs2.getString(“specs”));

row1.add(rs2.getString(“color”));

row1.add(rs2.getString(“size”));

row1.add(rs2.getString(“ref_no”));

row1.add(rs2.getString(“uom1”));

row1.add(“”);

row1.add(“”);

row1.add(“”);

produce.add(row1);

}

rs2.close();

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s