FTJ 11
-
Upload
sjcanand9541 -
Category
Documents
-
view
219 -
download
0
Transcript of FTJ 11
-
8/2/2019 FTJ 11
1/41
Design a Guard System for Sybil Attack
Introduction:
AS THE SCALE of a decentralized distributed system increases, the
presence of malicious behavior (e.g., Byzantine failures) becomes the norm rather
than the exception. Most designs against such malicious behavior rely on the
assumption that a certain fraction of the nodes in the system are honest. For
example, virtually all protocols for tolerating Byzantine failures assume that at
least 2/3 of the nodes are honest. This makes these protocols vulnerable to sybil
attacks [1], in which a malicious user takes on multiple identities and pretends to
be multiple, distinct nodes (called sybil nodes or sybil identities) in the system.
With sybil nodes comprising a large fraction (e.g., more than 1/3) of the nodes in
the system, the malicious user is able to out vote the honest users, effectively
breaking previous defenses against malicious behaviors. Thus, an effective
defense against sybil attacks would remove a primary practical obstacle to
collaborative tasks on peer-to-peer (p2p) and other decentralized systems
ABSTRACT
Peer-to-peer and other decentralized, distributed systems are known to beparticularly vulnerable to sybil attacks. In a sybil attack, a malicious user obtains
multiple fake identities and pretends to be multiple, distinct nodes in the system.
By controlling a large fraction of the nodes in the system, the malicious user isable to "out vote" the honest users in collaborative tasks such as Byzantine failure
defenses. This paper presents SybilGuard, a novel protocol for limiting the
corruptive influences of sybil attacks.
Our protocol is based on the "social network" among user identities, where anedge between two identities indicates a human-established trust relationship.
Malicious users can create many identities but few trust relationships.
-
8/2/2019 FTJ 11
2/41
EXISTING SYSTEM
In existing system, hackers easily can act as source node and sends
message to destination. Destination receives wrong message from hackers. Destination
believes that its correct message from source. Destination receives the wrong information
from hackers.
Messages are passed from sender to destination (receiver) without any
security. Message header holds source node information which sends the message to
receiver. Hackers can easily change that header information and sends to destination.
DISADVANTAGES
Destination gets the wrong information from hackers or malicious user.
There is no any server to detect hackers. Header information may be hiding by malicious
user. Source node does not get any response from destination while hackers get that
source information.
PROPOSED SYSTEM
In this proposed system, hackers can not act as source, because one
centralized server is maintaining to check authentication of source. This centralized
server is sybilguard. It blacks unauthorized users or hackers. Sybilguard is maintaining
source node information and header information of message. It checks the users using
that details whether they are attackers or normal user. Hackers information h as not been
transferred to destination. Destination has not been receiving any attacker information.
ADVANTAGES
Sybilguard is maintained to detect the attackers who are all act as source
node. It deletes that wrong information from hackers and indicates that they are attackers.
Hackers information has not transferred to receiver.
-
8/2/2019 FTJ 11
3/41
Sybilguard act as the centralized server to all users. It handles the message
transmission between those users. Each user has to register individually. Those user
informations are stored in centralized server and find the attackers using that information.
SYSTEM REQUIREMENTS
Software Requirements
Language : Java 1.5 or more
Backend : Sql sever
Operating System : Windows Xp
Hardware Requirements
Hard disk : 80 GB
SDRAM : 256 MB
Processor : P IV
Processor Speed : 2.33 GHz
MODULES
1. Topology Construction2. Node entry3. Message transmission4. Sybilguard
-
8/2/2019 FTJ 11
4/41
TOPOLOGY CONSTRUCTION
Topology construction is designed to construct one topology withavailable nodes. Register all nodes which are involved to transfer the data to some other
nodes. Depends upon total nodes, topology will be constructed.
Topology construction module allows you to construct node path. If
already exits, it will not allow to construct that same path. All nodes are mentioned in
topology construction. User cant modify node information after construction.
NODE ENTRY
Node entry module describes node authentication. To activate node who
are all involved in topology, node should be login into that topology. It does not allow
unauthorized node entry. Many nodes can enter into that mentioned topology. Each node
can send the messages to their destination after login.
MESSAGE TRANSMISSION
Each node (source node) can send the data to some other node(destination)
which one connected with that source node. While sending message, the source node
should mention the header information. Source node can send the data to destination.
Destination will receive that message.
SYBLGUARD
Sybilguard is maintained in this project to detect the attacker. Sybilguard
is called as centralized server. Sybilguard does not allow hackers to send the wrong data.
It compares node information and header information. If matches, normal user sending
-
8/2/2019 FTJ 11
5/41
the message to destination. Otherwise sybilguard will not allow the hackers to send
message. It blocks that data and it provides the attacker information to attacker.
Sybilguard gets node information from its registration. While data
transmission, sybilguard will get their header information. This centralized server
maintains to find out the attacker details.
The Java Language
What Is Java?
Java is two things: aprogramming languageand aplatform.
The Java Programming Language
Java is a high-level programming language that is all of the following:
Simple Object-oriented Distributed
Interpreted Robust Secure Architecture-neutral Portable High-performance Multithreaded
Dynamic
Java is also unusual in that each Java program is both compiled and interpreted.
With a compiler, you translate a Java program into an intermediate language called Java
byte codes--the platform-independent codes interpreted by the Java interpreter. With an
-
8/2/2019 FTJ 11
6/41
interpreter, each Java byte code instruction is parsed and run on the computer.
Compilation happens just once; interpretation occurs each time the program is executed.
This figure illustrates how this works.
Java byte codes can be considered as the machine code instructions for the Java
Virtual Machine (Java VM). Every Java interpreter, whether it's a Java development tool
or a Web browser that can run Java applets, is an implementation of the Java VM. The
Java VM can also be implemented in hardware.
Java byte codes help make "write once, run anywhere" possible. The Java
program can be compiled into byte codes on any platform that has a Java compiler. Thebyte codes can then be run on any implementation of the Java VM. For example, the
same Java program can run on Windows NT, Solaris, and Macintosh.
-
8/2/2019 FTJ 11
7/41
The Java Platform
A platform is the hardware or software environment in which a program runs. The
Java platform differs from most other platforms in that it's a software-only platform that
runs on top of other, hardware-based platforms. Most other platforms are described as a
combination of hardware and operating system.
The Java platform has two components:
The Java Virtual Machine (Java VM) The Java Application Programming Interface (Java API)
The Java API is a large collection of ready-made software components that
provide many useful capabilities, such as graphical user interface (GUI) widgets. The
Java API is grouped into libraries (packages) of related components.
The following figure depicts a Java program, such as an application or applet,
that's running on the Java platform. As the figure shows, the Java API and Virtual
Machine insulates the Java program from hardware dependencies.
http://../Non-IEEE/JD016/DJP042,jcmca016(SYBILGUARD%20NETWORK)/document/S/tutorial/figures/getStarted/2comp.gif -
8/2/2019 FTJ 11
8/41
As a platform-independent environment, Java can be a bit slower than native
code. However, smart compilers, well-tuned interpreters, and just-in-time byte code
compilers can bring Java's performance close to that of native code without threatening
portability.
What Can Java Do?
Probably the most well-known Java programs are Java applets. An applet is a
Java program that adheres to certain conventions that allow it to run within a Java-
enabled browser.
However, Java is not just for writing cute, entertaining applets for the World
Wide Web ("Web"). Java is a general-purpose, high-level programming language and a
powerful software platform. Using the generous Java API, we can write many types of
programs.
The most common types of programs are probably applets and applications,
where a Java application is a standalone program that runs directly on the Java platform.
How does the Java API support all of these kinds of programs? With
packages of software components that provide a wide range of functionality. The core
APIis the API
included in every full implementation of the Java platform. The core API givesyou the following features:
The Essentials: Objects, strings, threads, numbers, input and output,data structures, system properties, date and time, and so on.
Applets: The set of conventions used by Java applets.
-
8/2/2019 FTJ 11
9/41
Networking: URLs, TCP and UDP sockets, and IP addresses. Internationalization: Help for writing programs that can be localized
for users worldwide. Programs can automatically adapt to specific locales
and be displayed in the appropriate language. Security: Both low-level and high-level, including electronic signatures,
public/private key management, access control, and certificates.
Software components: Known as JavaBeans, can plug into existingcomponent architectures such as Microsoft's OLE/COM/Active-X
architecture, OpenDoc, and Netscape's Live Connect.
Object serialization: Allows lightweight persistence andcommunication via Remote Method Invocation (RMI).
Java Database Connectivity (JDBC):Provides uniform access to awide range of relational databases.
Java not only has a core API, but also standard extensions. The standard
extensions define APIs for 3D, servers, collaboration, telephony, speech, animation, and
more.
How Will Java Change My Life?
Java is likely to make your programs better and requires less effort than other
languages. We believe that Java will help you do the following:
Get started quickly: Although Java is a powerful object-orientedlanguage, it's easy to learn, especially for programmers already familiar
with C or C++.
Write less code: Comparisons of program metrics (class counts, methodcounts, and so on) suggest that a program written in Java can be four times
smaller than the same program in C++.
Write better code: The Java language encourages good codingpractices, and its garbage collection helps you avoid memory leaks. Java's
-
8/2/2019 FTJ 11
10/41
object orientation, its JavaBeans component architecture, and its wide-
ranging, easily extendible API let you reuse other people's tested code and
introduce fewer bugs.
Develop programs faster: Your development time may be as much astwice as fast versus writing the same program in C++. Why? You write
fewer lines of code with Java and Java is a simpler programming language
than C++.
Avoid platform dependencies with 100% Pure Java: You cankeep your program portable by following the purity tips mentioned
throughout this book and avoiding the use of libraries written in other
languages.
Write once, run anywhere: Because 100% Pure Java programs arecompiled into machine-independent byte codes, they run consistently on
any Java platform.
Distribute software more easily: You can upgrade applets easilyfrom a central server. Applets take advantage of the Java feature of
allowing new classes to be loaded "on the fly," without recompiling the
entire program.
JAVA PACKAGES AND API
AWT
The AWT classes contained by the java.awt package. It is one of
the largest packages. Because it is logically organized in a top-down, hierachical
fashion, it is easier to understand and use than you might at first believe.AWT contains
numerous classes and methods that allow you to create and manage windows. It also
explains further aspects of of javas event handling mechanism. The main purpose of the
AWT is to support applet windows, it can be used to create stand alone windows that
run in a GUI environment such as windows.
-
8/2/2019 FTJ 11
11/41
APPLET
The applet class is contained by thejava.applet package. Applet contains several
methods that give you detailed control over the execution of your applet. Java.applet
also defines three interfaces AppletContext, AudioClip, AppletStub. All applet must
import with java.applet .applets must also import with thejava.awt.
UTIL
The java.util package contains some of the most exiting
enhancements added by java 2 collections .a collections is group of objects the addition
of collections caused fundamental alterations in the structure and architecture of many
elements ofjava.util.java.util contains a wide range of functionality.thease classes and
interfaces are used throughout core java packages. These include classes that tokenize the
string, work with
dates, compute random numbers and observe events.
NET
Thejava.net package which provides support of networking. Java is good
language for networking the classes are defined in java.net package. These networking
classes encapsulate the socket paradigm pioneered by the BSD.
ZIP
Thejava.util.zip package provides the ability to read and write files in the popular ZIP
and GZIP formats. Both ZIP and GZIP input and output streams are available. Other
classes implement the ZLIB algorithms for compression and decompression.
SWING
The swing is a set of classes that provides more powerful and flexible
components than are possible with the AWT. Unlike AWT components Swing
components are not implemented by platform specific code. They are written entirely in
java and, therefore, are platform-independent. The term lightweight is used to describe
-
8/2/2019 FTJ 11
12/41
such elements. The number of classes and interfaces in the swing packages is
substancial. Swing is area that you will want to explore further on your own
APPLICATION PROGRAMMING INTERFACES
Listeners are created by implementing one or more of the interfaces Defined by
the java.awt.event package. When an event occurs, the event Source invokes the
appropriate method defined by the listener.
Action Listener interface
This interface defines the actionPerformed () method that is Invoked when an
action event occurs. Its general form is shown
Void actionPerformed (ActionEvent ae)
The mouselistener interface
Void windowActivated(WindowEvent we)
Void windowActivated(WindowEvent we)
This interface defines five methods.If the mouse is pressed and released at the same
point,mouseClicked() is invoked.Whenthe mouse enters a component,the mouseEntered()
method is called.When it leaves, mouseExited() is called. The mousePressedandmouseRealeased() methods are invoked when the mouse is pressed andreleased,
respectively.
The general forms of these methods are shown here:
Void mouseClicked(MouseEvent me)
Void mouseEntered(MouseEvent me)
Void mouseExited(MouseEvent me)
Void mousePressed(MouseEvent me)
Void mouseRealeased(MouseEvent me)
The MouseMotionListener interface
This interface defines two methods. The mouseDragged() method is called multiple
times as the mouse is dragged. The mouseMoved() method multiple times as the mouse
is moved. Their general forms are shown here:
-
8/2/2019 FTJ 11
13/41
-
8/2/2019 FTJ 11
14/41
Data Flow Diagram
DataBase
Topology creation
Insert
node
details
Nodes Login Server
Checknodeavailability
Data Transmission
Ithold
ssen
dera
ndre
ceive
rdeta
ils
node namecheck sender namewith database
Destination
Yes
Stop transmissionterminate sender
from network
No
-
8/2/2019 FTJ 11
15/41
Screen Shots
-
8/2/2019 FTJ 11
16/41
-
8/2/2019 FTJ 11
17/41
-
8/2/2019 FTJ 11
18/41
-
8/2/2019 FTJ 11
19/41
-
8/2/2019 FTJ 11
20/41
-
8/2/2019 FTJ 11
21/41
TESTING
Testing is the process of executing the program with the intent of finding errors.
During testing, the program to be tested is executed with a set of test cases and the output
of the program for the test cases is evaluated to determine the program is performing as it
is expected. Error is the testing fundamental and is defined as the difference between the
actual output of a software and a correct output i.e., difference between the actual and
ideal testing is usually relied upon to detect these faults in the coding phase for this,
different levels of testing are used which performs different tasks and aim to the test
different aspects of the system.
Goals for Testing
The famous statement byDijkstra(in Dahl et al. 1972) is a perfect synthesis of
the goals of the testing. If the results delivered by the system are different from the
expected ones in just one case, in this unequally shows that the system is incorrect: by
contrast, a correct behavior of the system on a finite number of cases does not guarantee
correctness in the general case. For instance, we could have built a program that behaves
properly for even integer numbers but not odd numbers. Clearly, any number of tests witheven input values will face to show the error.
Testing should be based on soundandsystematic techniques so that, after testing,we may have a better understanding of the products reliability.
Testing should help locate errors, not just detect their presence. The result oftesting should not be viewed as simply providing a Boolean answer to the
question of whether the software works properly or not.
Tests should be organized in a way that helps to isolate errors. This informationcan then be used in debugging.
Testing should be repeatable, i.e., tests should be arranged in such a way thatseparating the same experiment-supplying the same input data to the same piece
of codeproduces the same results.
-
8/2/2019 FTJ 11
22/41
Finally testing should be accurate this will increase the reliability of testing.Here we should observe that the accuracy of the testing activity depends on the
level of precision and may be even formality of software specifications.
Types Of Testing
Functional Testing Here the structure of the program is not considered. Only the test
cases are decided solely on the basis of the requirements or
specification of the program or module and the internal details of
the module or the program is not considered for the selection of
test cases. This is also called Black Box Testing.
Structural Testing It is considered with testing the implementation of the program.
The intention of the structural testing is not to exercise all the
different input and output conditions but to exercise the different
programming and data files used in the program. This testing is
also called White Box Testing.
Different Level of Testing
Unit Testing In it different modules are tested against the specifications
produced during design for the modules. It is essential for
verification of the code produced during the code phase and the
goal is to test the internal logic of the module.
-
8/2/2019 FTJ 11
23/41
Integration Testing The goal here is to see if the modules can be integrated properly,
the emphasis being on testing interfaces between modules. After
structural testing and functional testing we get error free modules
these modules are to be integrated to get the required results of the
system. After checking the module another module is tested and is
integrated with the previous module.
After the integration the test phases are generated and the resultsare tested.
System Testing Here the entire software is tested. The reference document for this
process is the requirement document and the goal is to see whether
the software needs its requirements.
The system was tested for various test cases with various inputs.
Acceptance Testing It is some times performed with realistic data of the client to
demonstrate that the software is working satisfactorily. Testing
here focus on the external behavior of the system, the internal logic
of the program is not emphasized.
In acceptance test the system is tested for various inputs.
-
8/2/2019 FTJ 11
24/41
Thus different types of testing are performed.
TEST ACTIVITIES IN SOFTWARE LIFE-CYCLE
Requirements
Design
Implementation
Test
Test planeneration
Test design
Generation
Test case
Generation
Test
procedure
Generation
Test
execution
-
8/2/2019 FTJ 11
25/41
CONCLUSION
In this paper it explained about secure transmission between the two nodes usingsybilguard. Sybilguard used to detect the hackers who are all act as source node.
In a sybil attack, a malicious user obtains multiple fake identities and pretends to
be multiple, distinct nodes in the system.
Malicious users can create many identities to act as source node but few trustrelationships (like sybilguard) are find theirs and avoid them to sending wrong
information to destination.
By controlling a large fraction of the nodes in the system, the malicious user isable to "out vote" the honest users in collaborative tasks such as Byzantine failure
defenses.
It provides the security while transferring message from source to destination.Destination does not get wrong information from wrong user. The attacker will be
detected by centralized server. Wrong information deleted from that destination.
Sample codes
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
import java.util.*;
import java.net.*;
import java.io.*;
import javax.swing.border.*;
-
8/2/2019 FTJ 11
26/41
public class connectnodes extends JFrame
{
// Variables declaration
private JLabel jLabel1;
private JLabel jLabel2;
private JLabel jLabel3;
private JLabel jLabel4,jLabel5;
private JTextField jTextField1;
private JComboBox jComboBox1;
private JComboBox jComboBox2;
private JTextField jTextField5;
private JButton jButton1;
private JButton jButton2;
private JButton jButton3;
private JButton jButton4,jButton5;
private JPanel contentPane;
private JPanel panel;
public Runtime r;
int n;
int i=0;
int portno;
String nodename = "",node,des;
String sysname = "";
ResultSet rs;
Connection cs;
Statement st;
Font font = new Font("TimesRoman",Font.PLAIN,20);
public Vector totalpeer = new Vector();
// End of variables declaration
-
8/2/2019 FTJ 11
27/41
public connectnodes()
{
super();
initializeComponent();
this.setVisible(true);
}
public void initializeComponent()
{
jLabel1 = new JLabel();
jLabel2 = new JLabel();
jLabel3 = new JLabel();
jLabel4 = new JLabel();
jLabel5 = new JLabel();
panel=new JPanel();
jTextField1 = new JTextField();
jTextField5 = new JTextField();
jButton1 = new JButton();
jButton2 = new JButton();
jButton3 = new JButton();
jButton4 = new JButton();
jButton5 = new JButton();
jComboBox1 = new JComboBox(totalpeer);
jComboBox2 = new JComboBox(totalpeer);
contentPane = (JPanel)this.getContentPane();
-
8/2/2019 FTJ 11
28/41
jLabel2.setText("Peer Name");
jLabel3.setText("Source Node");
jLabel4.setText("Neighbour Node");
jLabel5.setText("Enter no of Nodes");
jButton1.setText("Submit");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
if(i
-
8/2/2019 FTJ 11
29/41
}
i++;
}
}
});
jButton2.setText("Clear");
jButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField1.setText("");
jComboBox1.setSelectedItem("Select");
jComboBox2.setSelectedItem("Select");
}
});
jButton4.setText("Ok");
jButton4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
try
{
String nodecount=jTextField5.getText();
n=Integer.parseInt(nodecount);
System.out.println("n:"+n);
if(n!=0)
{
-
8/2/2019 FTJ 11
30/41
jTextField1.setEnabled(true);
jButton1.setEnabled(true);
jTextField5.setEnabled(false);
jButton4.setEnabled(false);
}
}
catch (Exception e1)
{
JOptionPane.showMessageDialog(null,"Please
Enter Value");
}
}
});
jButton3.setText("Cancel");
jButton3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
-
8/2/2019 FTJ 11
31/41
dispose();
}
});
jButton5.setText("Connection");
jButton5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton5_actionPerformed(e);
}
});
//
// contentPane
//
jTextField1.setEnabled(false);
jComboBox1.setEnabled(false);
jComboBox2.setEnabled(false);
jButton1.setEnabled(false);
contentPane.setLayout(null);
panel.setLayout(null);
addComponent(contentPane,panel, -5,-5,550,400);
addComponent(panel, jLabel2, 65,100,100,25);
addComponent(panel, jLabel3, 65,150,100,25);
-
8/2/2019 FTJ 11
32/41
addComponent(panel, jLabel4, 65,200,100,25);
addComponent(panel, jTextField1, 204,100,100,25);
addComponent(panel, jComboBox1, 204,150,100,25);
addComponent(panel,jComboBox2, 203,200,100,25);
addComponent(panel, jButton1, 400,85,100,25);
addComponent(panel, jButton2, 400,120,100,25);
addComponent(panel, jButton3, 400,155,100,25);
addComponent(panel, jButton5, 400,190,100,25);
addComponent(panel, jLabel5, 65,50,100,25);
addComponent(panel,jTextField5, 203,50,100,25);
addComponent(panel, jButton4, 400,50,100,25);
panel.setBackground(new Color(255,255,255));
Border etched=BorderFactory.createEtchedBorder();
Border border=BorderFactory.createTitledBorder(etched,"Node
Registration",TitledBorder.CENTER,TitledBorder.DEFAULT_JUSTIFICATION,font,C
olor.red);
panel.setBorder(border);
this.setTitle("Network Construction");
this.setLocation(new Point(100, 100));
this.setSize(new Dimension(550, 400));
this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
this.setResizable(false);
}
private void addComponent(Container container,Component c,int x,int y,int
width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}
-
8/2/2019 FTJ 11
33/41
private void jButton1_actionPerformed(ActionEvent e)
{
nodename = jTextField1.getText();
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cs=DriverManager.getConnection("jdbc:odbc:server");
st=cs.createStatement();
rs= st.executeQuery("select * from NodeInformation where
NodeName LIKE '"+nodename+"' "); //OR SystemName LIKE '"+sysname+"'
if(rs.next())
{
JOptionPane.showMessageDialog(this,"The given Data already Exists");
i--;
}
else
{ String query = "insert into NodeInformation
values('"+nodename+"','0','192.168.1.4','ON','')";
st.execute(query);
JOptionPane.showMessageDialog(this,"Registration Sucess fully
Completed");
jTextField1.setText("");
}
-
8/2/2019 FTJ 11
34/41
}
catch(Exception ee)
{
JOptionPane.showMessageDialog(this,"Specify the Correct
PortNo");
System.out.println("Connectivity Error");
ee.printStackTrace();
i--;
}
}
private void jButton5_actionPerformed(ActionEvent e)
{
try
{
node = (String)jComboBox1.getSelectedItem();
des = (String)jComboBox2.getSelectedItem();
System.out.println(""+node);
System.out.println(""+des);
if(node.equals("Select")||des.equals("Select"))
{
JOptionPane.showMessageDialog(this,"Specify the Nodes");
}
else if (node.equals(des))
{
-
8/2/2019 FTJ 11
35/41
JOptionPane.showMessageDialog(this,"Specify a Valid
Neighbour");
}
else
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cs=DriverManager.getConnection("jdbc:odbc:server");
st=cs.createStatement();
rs= st.executeQuery("select * from Connection where NodeName
LIKE '"+node+"' AND Neighbour LIKE '"+des+"'"); //OR SystemName LIKE
'"+sysname+"'
System.out.println("1");
if(rs.next())
{
JOptionPane.showMessageDialog(this,"The given Data already Exists");
}
else
{
String query = "insert into Connection
values('"+node+"','"+des+"','1','0')";
String query1= "insert into Connection
values('"+des+"','"+node+"','1','0')";
st.executeUpdate(query);
-
8/2/2019 FTJ 11
36/41
st.executeUpdate(query1);
JOptionPane.showMessageDialog(this,"Connection Information
Completed");
}
}
catch(SQLException ee)
{
JOptionPane.showMessageDialog(this,"Connectivity
Error");
System.out.println("Connectivity Error");
ee.printStackTrace();
}
}
}
catch (Exception e3)
{
JOptionPane.showMessageDialog(this,"Exception");
e3.printStackTrace();
}
}
public Vector connect()
{
try
{
-
8/2/2019 FTJ 11
37/41
-
8/2/2019 FTJ 11
38/41
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cs=DriverManager.getConnection("jdbc:odbc:server");
st=cs.createStatement();
}
catch (Exception e)
{
e.printStackTrace();
}
return st;
}
}
import java.sql.*;
import java.sql.Connection.*;
import java.net.*;
class limit
{
public Connection cs;
public Statement st;
public ResultSet rs,rs1,rs2;
double val1,val2,result1,result2;
int i,count = 0;
double res1[] = new double[10];
double res2[] = new double[10];
String path[] = new String[10];
-
8/2/2019 FTJ 11
39/41
String n[] = new String[10];
public Statement connect() throws Exception
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cs = DriverManager.getConnection("jdbc:odbc:server");
st = cs.createStatement();
}
catch (Exception e)
{
e.printStackTrace();
}
return st;
}
public void getval()
{
try
{
connect();
rs = st.executeQuery("select * from possiblepath");
while(rs.next())
{
n[i]=rs.getString(1);
path[i]=rs.getString(2);
val1 = Double.parseDouble(rs.getString(3));
val2 = Double.parseDouble(rs.getString(4));
-
8/2/2019 FTJ 11
40/41
System.out.println("rtc path:"+path);
System.out.println("\t"+val1+"\t"+val2);
result1 = Math.ceil(val1);
result2 = Math.ceil(val2);
System.out.println("\t"+result1+"\t"+result2);
res1[i]= result1;
res2[i]= result2;
i++;
}
try
{
rs2 = st.executeQuery("select count(*) from possiblepath");
while(rs2.next())
{
count =Integer.parseInt(rs2.getString(1));
System.out.println("Count :\t"+count);
}
}
catch (Exception ex1)
{
ex1.printStackTrace();
}
//st.execute("create table RTC (path varchar(20),limit varchar(20),delay
varchar(20))");
for (i=0;i
-
8/2/2019 FTJ 11
41/41
{
System.out.println("inside for
loop"+path[i]+"\t"+res1[i]+"\t"+res2[i]);
st.executeUpdate("insert into pda values
('"+path[i]+"','"+res1[i]+"','"+res2[i]+"','"+n[i]+"')");
}
}
catch (Exception ex)
{
ex.printStackTrace();
}}}