Posted by Anu Wed 14th Mar 2007 18:38 - Syntax is Java - 125 views
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...??

  1. import javax.swing.*;
  2. import java.util.*;
  3. import java.io.*;
  4. import java.sql.*;
  5. import java.net.*;
  6.  
  7. public class Database implements {
  8.     public strIPs,strDetHead,strDetailResults,strTimes;
  9.     public strSlctQuery=null;
  10.     //public int ind=-1;
  11.     public connection;
  12.        
  13.     //constructor used will be:-
  14.     public Database( ip, detailHead, result, time){
  15.             strIPs=ip;
  16.             strDetHead=detailHead;
  17.             strDetailResults=result;
  18.             strTimes=time;
  19.     }
  20.        
  21.     public void store(){
  22.            
  23.             //DATABASE CONNECTION
  24.          try{
  25.               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  26.               connection=.getConnection("jdbc:odbc:iirsdb");
  27.    
  28.             //INSERT INTO DATABASE
  29.             stmt1=connection.createStatement();
  30.             .out.println("b4 forming query, strSlctQuery= "+strSlctQuery);
  31.             strSlctQuery=formQuery2(strDetHead);
  32.            
  33.             System.out.println("THe insert query formed is:- "+strSlctQuery);
  34.             int r = stmt1.executeUpdate( strSlctQuery );                   
  35.             if (r==1)
  36.              .showMessageDialog(null,"Insertion into Database successful" );           
  37.             stmt1.close();
  38.         }catch( cnfex){
  39.             .err.println("Failed to load JDBC/ODBC driver");
  40.             cnfex.printStackTrace();
  41.         }
  42.         catch( sqlex){
  43.             .err.println("\nException in accessing Database:-" + sqlex);
  44.             sqlex.printStackTrace();
  45.         }   
  46.     }
  47.  
  48.         public formQuery2( strDetailHeads){
  49.             .out.println("\n Inside formquery2 with strDetailHeads= "+strDetailHeads);
  50.             strQuery1="";
  51.            
  52.             if(strDetailHeads=="OS Name")
  53.                 strQuery1="insert into tblStatic values('"+strIPs+"','"+strDetailResults+"','','','','','','','','','','','','','','"+strTimes+"')";
  54.            
  55.             else if(strDetailHeads=="OS Version")
  56.                 strQuery1="insert into tblStatic values('"+strIPs+"','','"+strDetailResults+"','','','','','','','','','','','','','"+strTimes+"')";
  57.            
  58.             else if(strDetailHeads=="OS Manufacturer")   
  59.                 strQuery1="insert into tblStatic values('"+strIPs+"','','','"+strDetailResults+"','','','','','','','','','','','','"+strTimes+"')";
  60.            
  61.             else if(strDetailHeads=="OS Configuration")
  62.                 strQuery1="insert into tblStatic values('"+strIPs+"','','','','"+strDetailResults+"','','','','','','','','','','','"+strTimes+"')";
  63.            
  64.             else if(strDetailHeads=="OS Build Type")   
  65.                 strQuery1="insert into tblStatic values('"+strIPs+"','','','','','"+strDetailResults+"','','','','','','','','','','"+strTimes+"')";
  66.            
  67.             else if(strDetailHeads=="Registered Owner")
  68.                 strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','"+strDetailResults+"','','','','','','','','','"+strTimes+"')";
  69.            
  70.             else if(strDetailHeads=="Registered Organization")
  71.                 strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','"+strDetailResults+"','','','','','','','','"+strTimes+"')";
  72.            
  73.             else if(strDetailHeads=="System Manufacturer")
  74.                 strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','','"+strDetailResults+"','','','','','','','"+strTimes+"')";
  75.            
  76.             else if(strDetailHeads=="System Model")
  77.                 strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','','','"+strDetailResults+"','','','','','','"+strTimes+"')";
  78.            
  79.             else if(strDetailHeads=="System type")
  80.                 strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','','','','"+strDetailResults+"','','','','','"+strTimes+"')";
  81.            
  82.             else if(strDetailHeads=="Processor(s)")
  83.                 strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','','','','','"+strDetailResults+"','','','','"+strTimes+"')";
  84.            
  85.             else if(strDetailHeads=="BIOS Version")
  86.                 strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','','','','','','"+strDetailResults+"','','','"+strTimes+"')";
  87.            
  88.             else if(strDetailHeads=="Total Physical Memory")
  89.                 strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','','','','','','','"+strDetailResults+"','','"+strTimes+"')";
  90.            
  91.             else if(strDetailHeads=="Network Card(s)")
  92.                 strQuery1="insert into tblStatic values('"+strIPs+"','','','','','','','','','','','','','','"+strDetailResults+"','"+strTimes+"')";
  93.            
  94.             else if(strDetailHeads=="Domain")
  95.                 strQuery1="insert into tblSemiDyn values('"+strIPs+"','"+strDetailResults+"','','','','','','"+strTimes+"')";
  96.            
  97.             else if(strDetailHeads=="Logon Server")
  98.                 strQuery1="insert into tblSemiDyn values('"+strIPs+"','','"+strDetailResults+"','','','','','"+strTimes+"')";
  99.            
  100.             else if(strDetailHeads=="Physical Address")
  101.                 strQuery1="insert into tblSemiDyn values('"+strIPs+"','','','"+strDetailResults+"','','','','"+strTimes+"')";
  102.            
  103.             else if(strDetailHeads=="Subnet Mask")
  104.                 strQuery1="insert into tblSemiDyn values('"+strIPs+"','','','','"+strDetailResults+"','','','"+strTimes+"')";
  105.            
  106.             else if(strDetailHeads=="Default Gateway")
  107.                 strQuery1="insert into tblSemiDyn values('"+strIPs+"','','','','','"+strDetailResults+"','','"+strTimes+"')";
  108.            
  109.             else if(strDetailHeads=="DNS Servers")
  110.                 strQuery1="insert into tblSemiDyn values('"+strIPs+"','','','','','','"+strDetailResults+"','"+strTimes+"')";
  111.            
  112.             else if(strDetailHeads=="Available Physical Memory")
  113.                 strQuery1="insert into tblDyn values('"+strIPs+"','"+strDetailResults+"','"+strTimes+"')";
  114.            
  115.             .out.println("INSERT QUERY FORMED IS:-"+strQuery1);   
  116.             return strQuery1;
  117.         }
  118. }

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

 

Comments: 0