Retrieve Record from Oracle Database Using JDBC API

Arushi
Updated on 30-Jul-2019 22:30:26

1K+ Views

You can update/modify the existing contents of a record in a table using the UPDATE query. Using this you can update all the records of the table or specific records.SyntaxUPDATE table_name SET column1 = value1, column2 = value2...., columnN = valueN WHERE [condition];To update the contents of a record in a table using JDBC API you need to −Register the Driver: Register the driver class using the registerDriver() method of the DriverManager class. Pass the driver class name to it, as parameter.Establish a connection: Connect to the database using the getConnection() method of the DriverManager class. Passing URL (String), username (String), password (String) ... Read More

What is JSON.parse() and Its Use in JavaScript

vineeth.mariserla
Updated on 30-Jul-2019 22:30:26

190 Views

JSON.parse()When the data is received from web server, the data is always a string .So to change it to the object, JSON.parse() method is used. Example Live Demo    var obj = '{"name":"Jon", "age":20, "city":"Columbia"}';    var res = JSON.parse(obj);    document.write(res);   console.log(res); output[object object] {"name":"Jon", "age":"20", "city":"Columbia"}

Set JLabel Content to Left Justified and Bottom Aligned in Java

Smita Kapse
Updated on 30-Jul-2019 22:30:26

221 Views

To set the text of the label component to be left-justified and bottom-aligned, you need to set the alignment. Set the label to be on the left and bottom aligned −JLabel label = new JLabel("Fav Sports", JLabel.LEFT); label.setVerticalAlignment(JLabel.BOTTOM);Here, we have set the size of the label as well as the color that includes foreground and background color −label.setPreferredSize(new Dimension(220, 70)); label.setOpaque(true); label.setBackground(Color.YELLOW); label.setForeground(Color.RED);The following is an example to set the content of the label to be left-justified and bottom-aligned −Examplepackage my; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextArea; import javax.swing.WindowConstants; public class SwingDemo {    public static void main(String[] args) {       JFrame frame = new JFrame("Frame");       frame.setLayout(new FlowLayout());   ... Read More

Retrieve Value from Table Cell with TableModel in Java

George John
Updated on 30-Jul-2019 22:30:26

853 Views

At first, create a table with DefaultTableModel −String data[][] = {    {"Australia", "5", "1"},    {"US", "10", "2"},    {"Canada", "9", "3"},    {"India", "7", "4"},    {"Poland", "2", "5"},    {"SriLanka", "5", "6"} }; String col [] = {"Team", "Selected Players", "Rank"}; DefaultTableModel tableModel = new DefaultTableModel(data, col); JTable table = new JTable(tableModel);Now, use the getModel() to retrieve the value from table cell −Object ob = table.getModel().getValueAt(3, 2); System.out.println("Value = "+ob);The following is an example to retrieve the value from a table cell with TableModel −Examplepackage my; import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JRootPane; import javax.swing.JScrollPane; import ... Read More

Retrieve Data from MySQL with Two Hyphen Symbols

Chandu yadav
Updated on 30-Jul-2019 22:30:26

565 Views

For this, use the LIKE operator. Let us first create a table:mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Password varchar(100)    ); Query OK, 0 rows affected (1.27 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Password) values('John@--123'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable(Password) values('---Carol234'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(Password) values('--David987'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(Password) values('Mike----53443'); Query OK, 1 row affected (0.30 sec)Display all records from the table using select ... Read More

Encrypt CLOB DataType in JDBC

Smita Kapse
Updated on 30-Jul-2019 22:30:26

328 Views

Creating an Encrypted LOB(CLOB or, BLOB)Oracle database from 11g onwards provides SecureFiles feature to encrypt the Large object files (LOBs). You can create a secure file using the SECUREFILE keyword as −CREATE TABLE table_name (    myClob CLOB ) LOB(myClob) STORE AS SECUREFILE;You can encrypt a secured file using Encrypt option for encryption you can use 3DES168 or, AES128 or, AES192 or, AES256 algorithm.CREATE TABLE encrypt_tab (    myClob CLOB ) LOB(myClob) STORE AS SECUREFILE encrypt_lob(    ENCRYPT USING 'AES256' );

Select Last Entry Without Using LIMIT in MySQL

Kumar Varma
Updated on 30-Jul-2019 22:30:26

1K+ Views

For this, you can use subquery. Let us first create a table −mysql> create table DemoTable    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(100)    -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name) values('John Smith'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(Name) values('David Miller'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(Name) values('Chris Brown'); Query OK, 1 row affected (0.22 sec)Display all records from the table using select statement −mysql> ... Read More

HTML DOM Section Object

AmitDiwan
Updated on 30-Jul-2019 22:30:26

251 Views

The HTML DOM Section Object represent the element of an HTML document.Let us create section objectSyntaxFollowing is the syntax −document.createElement(“SECTION”);ExampleLet us see an example of HTML DOM section object − Live Demo    body{       text-align:center;       background-color:#fff;       color:#0197F6;    }    h1{       color:#23CE6B;    }    .drop-down{       width:35%;       border:2px solid #fff;       font-weight:bold;       padding:8px;    }    .btn{       background-color:#fff;       border:1.5px dashed #0197F6;       height:2rem;       ... Read More

Absolute Difference Between the First X and Last X Digits of N

Arnab Chakraborty
Updated on 30-Jul-2019 22:30:26

446 Views

Here we will see how to get the differences between first and last X digits of a number N. The number and X are given. To solve this problem, we have to find the length of the number, then cut the last x digits using modulus operator. After that cut all digits from the number except first x digits. Then get the difference, and return the result. Let the number is N = 568424. The X is 2 so first two digits are 56, and last two digits are 24. The difference is (56 - 24) = 32.AlgorithmdiffFirstLastDigits(N, X)begin   ... Read More

Factorial of Large Number Using Boost Multiprecision Library

karthikeya Boyini
Updated on 30-Jul-2019 22:30:26

164 Views

To find the factorial of a large number, we can use the boost library. This library provides high precision numbers. Using boost multiprecision library we can get more precision than 64 bits.Example#include #include using boost::multiprecision::cpp_int; using namespace std; cpp_int Large_Fact(int number) {    cpp_int fact = 1;    for (int i = 1; i > fact >> endl; }Output9332621544394415268169923885626670049071596826438162146859296389521759999322 9915608941463976156518286253697920827223758251185210916864000000000000000000 000000

Advertisements