Posted by Anu Wed 14th Mar 2007 18:38 - Syntax is Java - 125 views
Download | New Post | Modify | Hide line numbers
Download | New Post | Modify | Hide line numbers
Description:
at the statement 'system.out.println --> insert query is'==i dont get null
value but just a blank...n my query isnt forming...??
at the statement 'system.out.println --> insert query is'==i dont get null
value but just a blank...n my query isnt forming...??
-
import javax.swing.*;
-
import java.util.*;
-
import java.io.*;
-
import java.sql.*;
-
import java.net.*;
-
-
public class Database implements {
-
public strIPs,strDetHead,strDetailResults,strTimes;
-
public strSlctQuery=null;
-
//public int ind=-1;
-
public connection;
-
-
//constructor used will be:-
-
public Database( ip, detailHead, result, time){
-
strIPs=ip;
-
strDetHead=detailHead;
-
strDetailResults=result;
-
strTimes=time;
-
}
-
-
public void store(){
-
-
//DATABASE CONNECTION
-
try{
-
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
-
connection=.getConnection("jdbc:odbc:iirsdb");
-
-
//INSERT INTO DATABASE
-
stmt1=connection.createStatement();
-
.out.println("b4 forming query, strSlctQuery= "+strSlctQuery);
-
strSlctQuery=formQuery2(strDetHead);
-
-
System.out.println("THe insert query formed is:- "+strSlctQuery);
-
int r = stmt1.executeUpdate( strSlctQuery );
-
if (r==1)
-
.showMessageDialog(null,"Insertion into Database successful" );
-
stmt1.close();
-
}catch( cnfex){
-
.err.println("Failed to load JDBC/ODBC driver");
-
cnfex.printStackTrace();
-
}
-
catch( sqlex){
-
.err.println("\nException in accessing Database:-" + sqlex);
-
sqlex.printStackTrace();
-
}
-
}
-
-
public formQuery2( strDetailHeads){
-
.out.println("\n Inside formquery2 with strDetailHeads= "+strDetailHeads);
-
strQuery1="";
-
-
if(strDetailHeads=="OS Name")
-
strQuery1="insert into tblStatic values('"+strIPs+"','"+strDetailResults+"','','','','','','','','','','','','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="OS Version")
-
strQuery1="insert into tblStatic values('"+strIPs+"','','"+strDetailResults+"','','','','','','','','','','','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="OS Manufacturer")
-
strQuery1="insert into tblStatic values('"+strIPs+"','','','"+strDetailResults+"','','','','','','','','','','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="OS Configuration")
-
strQuery1="insert into tblStatic values('"+strIPs+"','','','','"+strDetailResults+"','','','','','','','','','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="OS Build Type")
-
strQuery1="insert into tblStatic values('"+strIPs+"','','','','','"+strDetailResults+"','','','','','','','','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="Registered Owner")
-
strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','"+strDetailResults+"','','','','','','','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="Registered Organization")
-
strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','"+strDetailResults+"','','','','','','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="System Manufacturer")
-
strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','','"+strDetailResults+"','','','','','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="System Model")
-
strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','','','"+strDetailResults+"','','','','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="System type")
-
strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','','','','"+strDetailResults+"','','','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="Processor(s)")
-
strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','','','','','"+strDetailResults+"','','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="BIOS Version")
-
strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','','','','','','"+strDetailResults+"','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="Total Physical Memory")
-
strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','','','','','','','"+strDetailResults+"','','"+strTimes+"')";
-
-
else if(strDetailHeads=="Network Card(s)")
-
strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','','','','','','','','"+strDetailResults+"','"+strTimes+"')";
-
-
else if(strDetailHeads=="Domain")
-
strQuery1="insert into tblSemiDyn values('"+strIPs+"','"+strDetailResults+"','','','','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="Logon Server")
-
strQuery1="insert into tblSemiDyn values('"+strIPs+"','','"+strDetailResults+"','','','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="Physical Address")
-
strQuery1="insert into tblSemiDyn values('"+strIPs+"','','','"+strDetailResults+"','','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="Subnet Mask")
-
strQuery1="insert into tblSemiDyn values('"+strIPs+"','','','','"+strDetailResults+"','','','"+strTimes+"')";
-
-
else if(strDetailHeads=="Default Gateway")
-
strQuery1="insert into tblSemiDyn values('"+strIPs+"','','','','','"+strDetailResults+"','','"+strTimes+"')";
-
-
else if(strDetailHeads=="DNS Servers")
-
strQuery1="insert into tblSemiDyn values('"+strIPs+"','','','','','','"+strDetailResults+"','"+strTimes+"')";
-
-
else if(strDetailHeads=="Available Physical Memory")
-
strQuery1="insert into tblDyn values('"+strIPs+"','"+strDetailResults+"','"+strTimes+"')";
-
-
.out.println("INSERT QUERY FORMED IS:-"+strQuery1);
-
return strQuery1;
-
}
-
}
PermaLink to this entry https://pastebin.co.uk/11874
Posted by Anu Wed 14th Mar 2007 18:38 - Syntax is Java - 125 views
Download | New Post | Modify | Hide line numbers
Download | New Post | Modify | Hide line numbers
Comments: 0