Found 317 Articles for JDBC

What is Statement in JDBC?

Nancy Den
Updated on 30-Jul-2019 22:30:25

516 Views

The Statement interface represents the static SQL statement, it is used to create and execute general purpose SQL statements using Java programs.Creating a statementYou can create an object of this interface using the createStatement() method of the connection interface. Create a statement by invoking this method as shown below.Statement stmt = null; try {    stmt = conn.createStatement( );    . . . } catch (SQLException e) {    . . . } finally {    . . . }Executing the Statement objectOnce you have created the statement object you can execute it using one of the execute methods namely, ... Read More

What is type2 driver of JDBC what are the advantages and disadvantages of it?

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

650 Views

This driver is known as a native API driver. This driver receives the calls from Java application and converts them in to vender specific native API calls. Here, we need to install The vendor-specific driver on the client machines.If we change the Database, we have to change the native API, as it is specific to a database and they are mostly obsolete now, but you may realize some speed increase with a Type 2 driver because it eliminates ODBC's overhead.Advantages of type2 driverFollowing are the advantages of the type2 driver.This type of driver fastest among all the 4 types of ... Read More

What is the MySQL JDBC driver connection string?

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

320 Views

The MySQL JDBC connection string look like this − Class.forName("com.mysql.jdbc.Driver"); Above, Driver is an interface. Whenever your JDBC is running outside an application server, then the class DriverManager establish the connection. The DriverManager class is as follows − conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/yourdatabaseName",”yourRootName","yourPassword"); Now, I am applying the above connection string to connect Java to MySQL database. The code is as follows. The following is the output that shows that MySQL connection with Java is successful.

How to find the Odd and Even numbers in an Array in java?

Govinda Sai
Updated on 19-Feb-2020 10:54:29

2K+ Views

In the loop check, the result of i%2 operation on each element if 0 the element is even else the element is odd.ExampleLive Demopublic class OddNumbersInAnArray {    public static void main(String args[]) {       int[] myArray = {23, 93, 56, 92, 39};       System.out.println("Even numbers in the given array are:: ");       for (int i=0; i

How to convert Byte Array to Image in java?

V Jyothi
Updated on 30-Jul-2019 22:30:20

17K+ Views

Java provides ImageIO class for reading and writing an image. To convert a byte array to an image.Create a ByteArrayInputStream object by passing the byte array (that is to be converted) to its constructor.Read the image using the read() method of the ImageIO class (by passing the ByteArrayInputStream objects to it as a parameter).Finally, Write the image to using the write() method of the ImageIo class.Exampleimport java.io.ByteArrayOutputStream; import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; public class ByteArrayToImage { public static void main(String args[]) throws Exception { BufferedImage bImage = ImageIO.read(new File("sample.jpg")); ... Read More

Not able to save a SAP Crystal Report for Enterprise 4.2

John SAP
Updated on 17-Feb-2020 12:41:56

100 Views

Note that you need to check if Crystal Report for Enterprise 2016 support specific IBM DB2 version and for this you need to check product compatibility guide for development.Are you using Universe developed on IBM DB2 then you need to ensure that you are using correct version of drivers JDBC/ODBC in IDT to create a Relational connection. You also need to ensure that connection is also published to SAP BI repository. If your version of DB2 and Crystal Reports is ok, I would recommend you follow below steps:First steps is to start, you need to create a System DSN in ... Read More

Setting up a JDBC connection to remote SAP HANA system

Manikanth Mani
Updated on 05-Dec-2019 09:36:57

684 Views

You are using the correct Port number for instance number “00”. Port number 300315, here 00 represents instance number of your HANA system.Try using HANA client jar file ngdbc.jar instead of SAP Jar file.try {    Class.forName("com.sap.db.jdbc.Driver");    String url ="jdbc:sap://xx.x.x.xxx:30015/DBNAME"; //IP Address of HANAsystem followed by Port number    String user ="user";    String password = "password";    Connection cn = java.sql.DriverManager.getConnection(url, user, password);    ResultSet rs = cn.createStatement().executeQuery("CALL Test.STORED_PROC");    // ...Enter the action here } catch(Exception e) {    e.printStackTrace(); }

Advertisements