Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8950

Re: Start Database command "AS" with number = exception

$
0
0

The following code sample works for me. I see the database started correctly in the server window and I can connect to it from dbisql.

 

import java.io.*;
import java.sql.*;
import java.util.*;
class T
{    public static void main (String args[]) throws IOException    {  Connection    con = null;       con = connect();       if( con == null ) {          return; // exception should already have been reported       }       try {          con.createStatement().execute( "START DATABASE 'test.db' AS \"1234\"" );          con.close();          System.out.println( "Disconnected" );       } catch (SQLException sqe) {          printExceptions(sqe);       }    }      private static Connection connect()    {       String    conn_str, url;       Connection  connection;       conn_str = "jdbc:sqlanywhere:uid=DBA;pwd=sql";       try {          connection = DriverManager.getConnection( conn_str );       }  catch( Exception e ) {          System.err.println( "Error! Could not connect" );          System.err.println( e.getMessage() );          printExceptions( (SQLException)e );          connection = null;       }       return connection;    }    static private void printExceptions(SQLException sqe)    {        while (sqe != null)        {              System.out.println("Unexpected exception : " +            "SqlState: " + sqe.getSQLState()  +            " " + sqe.toString() +            ", ErrorCode: " + sqe.getErrorCode());               System.out.println( "======================================" );                      sqe = sqe.getNextException();         }    }
}

Viewing all articles
Browse latest Browse all 8950

Trending Articles