Create a Database in MySQL from Java

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

2K+ Views

The following is the code to create a database in MySQL from Java. We are creating the database with name, “Customer_Tracker_Database”import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; public class CreateDatabaseDemo {    public static void main(String[] args) {       Connection con=null;       Statement stmt=null;       String yourDatabaseName="Customer_Tracker_Database";       try {          con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test3?useSSL=false",          "root", "123456");          stmt = con.createStatement();          int status = stmt.executeUpdate("CREATE DATABASE "+yourDatabaseName);          if(status > 0) {             System.out.println("Database ... Read More

Execute Both If and Else Statements Simultaneously in C/C++

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

232 Views

In this section we will see how to execute the if and else section simultaneously in a C or C++ code. This solution is little bit tricky.When the if and else are executed one after another then it is like executing statements where if-else are not present. But here we will see if they are present how to execute them one after another.Example Code#include using namespace std; int main() {    int x = 10;    if(x > 5)   {       lebel_1: cout

Use remove() in Android CopyOnWriteArrayList

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

144 Views

Before getting into example, we should know what CopyOnWriteArrayList is. It is a thread-safe variant of ArrayList and operations add, set, and so on by making a fresh copy of the underlying array.This example demonstrate about How to use remove() in android CopyOnWriteArrayListStep 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 CopyOnWriteArrayList elements.Step 3 − Add the following code to src/MainActivity.javapackage ... Read More

IP Address IPv4 and IPv6 Manipulation Library in Python

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

950 Views

Internet Protocol is currently in the process of moving from version 4 to version 6. This is necessitated because version 4 doesn’t provide enough addresses to handle the increasing number of devices with direct connections to the internet.An IPv4 address is composed of 32 bits, represented into four eight bit groups called as "octets". This is a "dotted decimal" format where each eight-bit octet can have a decimal value 0 to 255.For example: 192.168.1.1IPv4 address with CIDR notation: 192.168.1.1/24 where 24 means first three octets identify the network and last octet identifies node.An IPv6 address is 128 bits long. It ... Read More

Create Random BigInteger Within a Given Range in Java

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

386 Views

Create a Random class object −Random random = new Random();Now let us create a random BigInteger within the range set below −BigInteger i = new BigInteger(1024, random);Example Live Demoimport java.math.BigInteger; import java.util.Random; public class Demo {    public static void main(String[] args) {       Random random = new Random();       BigInteger i = new BigInteger(1024, random);       System.out.println("Random BigInteger = "+i);    } }OutputRandom BigInteger = 172988250696765715389833755481951104504569480256142363412177847577736195982554760981595486734850686498607899498518922990162874103419942352546847073039976287403845518172884710426458735414702299598858093908453406020426533304237452347610248118892069951238970445771615614781904759399589093691142208659284351662649

Need for Long Data Type in C and C++

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

189 Views

In C or C++, there are four different datatypes, that are used for integer type data. These four datatypes are short, int, long and long long. Each of these datatypes takes different memory spaces. The size varies in different architecture and different operating systems. Sometimes int takes 4-bytes or sometimes it takes 2-bytes. This also happen for the compilers. So we can use cross compilers.The cross compilers are basically a compiler, which is capable of compiling for a platform other than current platform.So if we want to compile the following code in 32bit system, and 64-bit system, it will generate ... Read More

Double Buffer Wrap Method in Java

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

138 Views

A double array can be wrapped into a buffer using the method wrap() in the class java.nio.DoubleBuffer. This method requires a single parameter i.e. the array to be wrapped into a buffer and it returns the new buffer created. If the returned buffer is modified, then the contents of the array are also similarly modified and vice versa.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) {       try {          double[] arr = { 8.7D, 1.5D, 3.2D, 7.4D, 5.9D ... Read More

Memory Read (MR) Machine Cycle in 8085 Microprocessor

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

8K+ Views

The last three clock cycles in ‘MOV C, M’ instruction are the example for Memory Read machine cycle. Waveforms for Machine Read machine cycle is shown below: InstructionOperationAddress reg.LDA 1234HLoading W with 12H (or Z with 34H)PCPOP BPopping information from stack topSPMOV C, MLoading A from memory pointed by HLHLLDAX BLoading A from memory pointed by BCBCLDAX DLoading A from memory pointed by DEDELDA 1234HLoading A from memory Location 1234HWZ The data, which is received in a register during a Memory Read machine cycle depends on the MR machine cycle within an instruction as shown below. Where ‘r’ stands for any of ... Read More

Update ListView After Inserting Values in Android SQLite

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

924 Views

Before getting into an example, we should know what SQLite database in android is. SQLite is an opensource SQL database that stores data to a text file on a device. Android comes in with built-in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrates How to update listview after insert values in Android SQLite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create ... Read More

Is PHP deg2rad Equal to MySQL RADIANS?

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

126 Views

Yes, both of these methods convert a degree value to radian. Let us create a table to understand MySQL radians. The query to create a table is as followsmysql> create table RadiansDemo    - > (    - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    - > Value int    - > ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into RadiansDemo(Value) values(0); Query OK, 1 row affected (0.14 sec) mysql> insert into RadiansDemo(Value) values(45); Query OK, 1 row affected (0.17 sec) mysql> insert into ... Read More

Advertisements