Create a Table in a Database Using JDBC API

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

6K+ Views

A. You can create a table in a database using the CREATE TABLE query.SyntaxCREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype, ..... columnN datatype, PRIMARY KEY( one or more columns ) );To create a table in a database 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 ot 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() ... Read More

Use Remaining Capacity in Android PriorityBlockingQueue

Samual Sam
Updated on 30-Jul-2019 22:30:25

159 Views

Before getting into the example, we should know what PriorityBlockingQueue is. It is an unbounded queue and follows the same order as a priority queue. The main usage of priority blocking queue is, it going to handle out of memory error.This example demonstrates about How to use remainingCapacity() in android PriorityBlockingQueueStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have taken a text view to show PriorityBlockingQueue ... Read More

urllib RobotParser: Parser for robots.txt in Python

Nitya Raut
Updated on 30-Jul-2019 22:30:25

708 Views

Web site owners use the /robots.txt file to give instructions about their site to web robots; this is called The Robots Exclusion Protocol. This file is a simple text-based access control system for computer programs that automatically access web resources. Such programs are called spiders, crawlers, etc. The file specifies the user agent identifier followed by a list of URLs the agent may not access.For example#robots.txt Sitemap: https://example.com/sitemap.xml User-agent: * Disallow: /admin/ Disallow: /downloads/ Disallow: /media/ Disallow: /static/This file is usually put in the top-level directory of your web server.Python's urllib.robotparser module provides RobotFileParser class. It answers questions about whether ... Read More

Adjust LocalDate to First Day of Next Month with TemporalAdjusters Class

Samual Sam
Updated on 30-Jul-2019 22:30:25

351 Views

Let us first set a date −LocalDate localDate = LocalDate.of(2019, Month.JUNE, 15);Now, adjust LocalDate to first Day of next month −LocalDate day = localDate.with(TemporalAdjusters.firstDayOfNextMonth());Example Live Demoimport java.time.LocalDate; import java.time.Month; import java.time.temporal.TemporalAdjusters; public class Demo {    public static void main(String[] args) {       LocalDate localDate = LocalDate.of(2019, Month.JUNE, 15);       System.out.println("Current Date = "+localDate);       System.out.println("Current Month = "+localDate.getMonth());       LocalDate day = localDate.with(TemporalAdjusters.firstDayOfMonth());       System.out.println("First day of month = "+day);       day = localDate.with(TemporalAdjusters.firstDayOfNextMonth());       System.out.println("First day of next month = "+day);    } }OutputCurrent Date ... Read More

lrint and llrint in C++

Anvi Jain
Updated on 30-Jul-2019 22:30:25

131 Views

In this section we will see the lrint() and llring() in C++. At first let us discuss about the lrint().The lrint() function is used to round the fractional given value in the argument to an integral value using current rounding mode. The current mode is determined by using fesetround().>=This lrint() function takes the double or float or integer value as input parameter, and returns the long int value by rounding the fractional part into an integral part.Example#include #include #include using namespace std; main() {    int x = 40;    long int res;    fesetround(FE_DOWNWARD); // setting ... Read More

FloatBuffer asReadOnlyBuffer Method in Java

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

103 Views

A read-only float buffer can be created using the contents of a buffer with the method asReadOnlyBuffer() in the class java.nio.FloatBuffer. The new buffer cannot have any modifications as it is a read-only buffer. However, the capacity, positions, limits etc. of the new buffer are the same as the previous buffer.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo {    public static void main(String[] args) {       int n = 5;       try {          FloatBuffer buffer = FloatBuffer.allocate(5);          buffer.put(4.5F); ... Read More

Interfacing a Matrix Keyboard with 8085 Microprocessor

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

7K+ Views

In a matrix keyboard there are keys which are arranged in the form of a matrix which consists of several rows and columns. In the figure which is stated below significantly indicates the interfacing process of a matrix keyboard which consists four rows and four columns respectively. We connect a key at the intersection of every rows and columns. Hence there is a total of 4 × 4 = 16 keys in the given matrix. The lines of the columns get connected to Gnd through pull-down resistors.Even there is a matrix size were to be 8 × 8, for a sum ... Read More

Append Data from TreeMap to ArrayList for ListView in Android

Anvi Jain
Updated on 30-Jul-2019 22:30:25

235 Views

This example demonstrate about How to append data from tree map to array list for list view in AndroidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                                     In the above code, we have taken the name and record number as Edit text, when user click on save button it will store the data into ... Read More

Implement Start Sticky for a Service

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

2K+ Views

Before getting into an example, we should know what service is in android. Service is going to do back ground operation without interacting with UI and it works even after activity destroy.START_STICKY -  If service is started with START_STICKY return type, it going to work in back ground even if activity is not foreground if android forcefully closed service due to memory problem or some other cases, it will restart service without interaction of the user.This example demonstrates How to implementing START_STICKY for a service.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and ... Read More

Find Out Changes in Device Airplane Mode on Android

Nitya Raut
Updated on 30-Jul-2019 22:30:25

713 Views

This example demonstrate about How to find device airplane mode is changed in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. In the above code, we have taken text view to show deice airplane status.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.SuppressLint; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.os.BatteryManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.util.Log; import ... Read More

Advertisements