Remove Record from Existing Table in Oracle Database Using JDBC API

Vikyath Ram
Updated on 30-Jul-2019 22:30:26

635 Views

You can remove a particular record from a table in a database using the DELETE query.SyntaxDELETE FROM table_name WHERE [condition];To delete a record from 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) as parameters to it.Create Statement: Create a Statement object using the createStatement() method of the Connection interface.Execute the Query: Execute the query using the executeUpdate() method of the ... Read More

Check If a Field in MongoDB is OR

Nishtha Thakur
Updated on 30-Jul-2019 22:30:26

187 Views

To check if a field in MongoDB is [] or {}, you can use the following syntax −db.yourCollectionName.find({    "yourOuterFieldName": { "$gt": {} },    "yourOuterFieldName.0": { "$exists": false } });Let us first create a collection with documents -> db.checkFieldDemo.insert([ ...   { _id: 1010, StudentDetails: {} }, ...   { _id: 1011, StudentDetails: [ { StudentId: 1 } ] }, ...   { _id: 1012, StudentDetails: [ {} ] }, ...   { _id: 1013 }, ...   { _id: 1014, StudentDetails: null}, ...   { _id: 1015, StudentDetails: { StudentId: 1 } } ... ]); BulkWriteResult({    "writeErrors" ... Read More

Change Default Font of JTabbedPane Tabs in Java

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

436 Views

To display the default font of the tabs, you need to use the Font class. Let’s say we created a JTabbedPane in Java −JTabbedPane tabbedPane = new JTabbedPane();Now, set the Font with font face, style and font size −Font font = new Font("Arial", Font.CENTER_BASELINE, 20); tabbedPane.setFont(font);The following is an example to change the default font of the JTabbedPane tabs −package my; import javax.swing.*; import java.awt.*; public class SwingDemo {    public static void main(String args[]) {       JFrame frame = new JFrame("Technologies");       JTabbedPane tabbedPane = new JTabbedPane();       JPanel panel1, panel2, panel3, panel4, ... Read More

Set Color of a Single Tab's Text in JTabbedPane in Java

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

526 Views

To set the the color of a single tab’s text, use the setForegroundAt() method. This gives an option to mention the index and the color. The index here is the index of the specific tab you want to color the text.Let us first create a JTabbedPane −JTabbedPane tabbedPane = new JTabbedPane();Now, set the background color for one of the tabs with index 2 −tabbedPane.setForegroundAt(2, Color.RED);The following is an example wherein we will update the foreground color of a single tab in the JTabbedPane −Examplepackage my; import javax.swing.*; import java.awt.*; public class SwingDemo {    public static void main(String args[]) { ... Read More

Creating a MySQL Table with Constraints

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

220 Views

No, you need to use open and close parenthesis like this ( ) while creating a table. Use the below syntax −CREATE TABLE IF NOT EXISTS yourTableName (    yourColumnName1 dataType1,    .    .    .    .    .    N );Let us first create a table −mysql> CREATE TABLE IF NOT EXISTS DemoTable    (    CustomerId int,    CustomerName varchar(20),    CustomerAge int    ,    PRIMARY KEY(CustomerId)    ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1, 'Chris', 25); Query OK, 1 row ... Read More

HTML ol start Attribute

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

128 Views

The start attribute of the element is used to set the start value of the first list item.. Following is the syntax−Above, num is the number set for the start value of the first list item. Let us now see an example to implement the start attribute of the element−Example Live Demo Last Semester MCA Result Rank from 1-5 Steve David Kane William John Rank from 5-10 Tom Jack Will ... Read More

Get Data Type Name from Java SQL Type Code Using JDBC

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

803 Views

The java.sql.Types class represents the SQL datatype in integer format. The valueOf() method of the enumeration JDBCType accepts an integer value representing the java.sql.Type and, returns the JDBC type corresponding to the specified value.ExampleLet us create a table with name MyPlayers in MySQL database using CREATE statement as shown below −CREATE TABLE MyPlayers(    ID INT,    First_Name VARCHAR(255),    Last_Name VARCHAR(255),    Date_Of_Birth date,    Place_Of_Birth VARCHAR(255),    Country VARCHAR(255),    PRIMARY KEY (ID) );Following JDBC program establishes connection with the MySQL database retrieves the contents of the MyPlayers table into a ResultSet object, obtains its metadata, obtains the column ... Read More

Sum the Values in a Column in MySQL

Rama Giri
Updated on 30-Jul-2019 22:30:26

370 Views

For this, use the aggregate function SUM(). Let us first create a table −mysql> create table DemoTable    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> € int    -> ); Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(€) values(10); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(€) values(200); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(€) values(190); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from ... Read More

HTML DOM Option DefaultSelected Property

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

123 Views

The HTML DOM option defaultSelected property returns the default value of option element in an HTML document.SyntaxFollowing is the syntax −object.defualtSelectedExampleLet us see an example of defaultSelected property − Live Demo    html{       height:100%;    }    body{       text-align:center;       color:#fff;       background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) center/cover no-repeat;       height:100%;    }    p{       font-weight:700;       font-size:1.2rem;    }    .drop-down{       width:35%;       border:2px solid #fff;       font-weight:bold;       padding:8px; ... Read More

Absolute Distinct Count in a Sorted Array

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

217 Views

In this section we will see how to count how many of elements whose absolute values are distinct? Suppose in an array there are few elements like {5, 5, 6, -5, 8, 2, -2, 1}, so there are 8 elements. But there are 5 elements {5, 6, 8, 2, 1} which are distinct. The -5 and 5 are not considered as different, they are same as their absolute value is same.To solve this problem, we will use the Set data-structure. In set duplicate elements are not allowed. And when we are inserting item into the set, we will push only ... Read More

Advertisements