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
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"}
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
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
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
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' );
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
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
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
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