小编use*_*751的帖子

java.sql.SQLException:Io异常:端口号的数字格式无效

package jdbcconnection;

import java.sql.*;

public class Jdbc2{

    public static void main(String[] args) throws Throwable {

        //Resgister the driver through 

         Class.forName("oracle.jdbc.driver.OracleDriver");
         System.out.println("registered driver successfully");
         //Create the connection and assign to connection reference
         Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:CUSTDB", "scott", "tiger");
         System.out.println("connection successsfully");
         //create a statement through connection reference and assign to statement reference
         Statement stmt=con.createStatement();
         System.out.println("statement object created successfully");
         //call the executequery method through statement reference and pass the query as argument.
         ResultSet rs=stmt.executeQuery("select * from emp");

         System.out.println("query is executed");

         while(rs.next()){
             int i=rs.getInt(1);
             String str=rs.getString(2); …
Run Code Online (Sandbox Code Playgroud)

java jdbc ojdbc

-2
推荐指数
1
解决办法
4万
查看次数

标签 统计

java ×1

jdbc ×1

ojdbc ×1