Tags: oracle java JDBC Path databaseGenerally after writing import oracle.jdbc.driver.*; Statement, you will find an error. At this point you need:First, add the JDBC driver to the ClasspathTwo different methods. One is graphical, computer-Properties-Advanced settings-Environment variables-edit path, add absolute path \JDBC driver name such as C:\jdbc\lib\ojdc6.jar; Here the JDBC driver has a version of the
process remember to introduce the JAR package Import java.sql.*; public class Fenye { public static void Main (String [] args) { try{ Class.forName ("Oracle.jdbc.driver.OracleDriver"); Connection ct=drivermanager.getconnection ("Jdbc:oracle:thin:@127.0.0.1:1521:orcl", "Scott", "Tiger"); ORCL-bit database name CallableStatement Cs=ct.preparecall ("{Call Fenye (?,?,?,?,?,?)}"); To give? Assign value Cs.setst
Nonsense not to say more, directly to everyone to paste the key code, the specific code as follows:
Package com.sp.test;
Import java.sql.*;
Import java.util.*;
public class Text_lianxi extends Thread {public void run () {try {yunxing ();
Thread.Sleep (10000);
The catch block (Interruptedexception e) {//TODO automatically generated catch blocks E.printstacktrace ();}
Input function Public string[] Shuru () {System.out.println () Enter the details of the examinee in order: \ n Test grade, I
If Oracle is set to be inaccessible for a certain period of time, the connection will be automatically closed, so that when Java accesses Oracle again, an IO exception will occur.Solution: Add the following configuration information to the spring datasource configuration.
notestablish the Connection" Wh Ile connecting to Oracle Database 11g [ID947653.1]
Change the JDBC connection driver class Inyour application Server from:
Oracle.jdbc.driver.OracleDriverToOracle.jdbc.OracleDriver
2.4 Using TNS Name:dvd
String Dburl = "Jdbc:oracle:thin: @dvd";
The error is as follows:
Java.sql.SQ
above objects individually, because if you do not close it, it will affect performance and consume resources $ //Note the order of the closing, the last used first closePanax Notoginseng if(Result! =NULL) - result.close (); the if(Pre! =NULL) + pre.close (); A if(Con! =NULL) the con.close (); +SYSTEM.OUT.PRINTLN ("The database connection is closed! "); -
Packageconnectionoracledatabase;Importjava.sql.Connection;ImportJava.sql.DatabaseMetaData;ImportJava.sql.DriverManager;Importjava.sql.PreparedStatement;ImportJava.sql.ResultSet;Importjava.sql.SQLException; Public classConnectionoracledatabaseutil {/*** This is a successful case of connecting Oracle database *@paramargs*/ Public Static voidMain (string[] args) {//get
Event: The report interface database was suddenly unable to connect, resulting in an inability to count operations properly. Exception information: Io exception: Got minus one from a read call analysis: The database address and its configuration information are changed, after the query that the database adjusted to the cluster working mode. Results: 1. Modify the
off JDBC (open back off)
the rst.close (); - st.close (); $ con.close (); the}Catch(ClassNotFoundException e) { the e.printstacktrace (); the }
the Catch(SQLException e) { - e.printstacktrace (); in }
the }
the PublicString Getdriver () { About returndriver; the }
the Public voidsetdriver (String driver) { the This. Driver =driver; + }
- PublicString GetUrl () { the returnURL;Bayi }
the Public voidse
Tags:idt nodes borderjdbc2.0 contains add1.5oracle database Format one: Use ServiceName mode:Jdbc:oracle:thin:@//Example Jdbc:oracle:thin:@//xxx.xxx.xxx.xxx:1526/cdevAfter @ there is//, which is the main difference from using SIDS. (11g does not add after @//OK)This format is the recommended format for Oracle.Because the SID for each node is different for the cluster, the service name can contain all nodes.Format two: Use SID mode:Jdbc:oracle:thin:@
A packaged tool class that links Oracle databases to easily get connection objects to close statement, ResultSet, statment objects, and so on
Copy Code code as follows:
Package myutil;
Import java.sql.Connection;
Import Java.sql.DriverManager;
Import java.sql.PreparedStatement;
Import Java.sql.ResultSet;
Import java.sql.SQLException;
Import java.sql.Statement;
/**
* Link
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.