⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 driver.java

📁 第三方的SQL Server and Sybase的jdbc dirver,速度更快
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            if (choicesMap.containsKey(name)) {                info.choices = (String[]) choicesMap.get(name);            }            dpi[i] = info;        }        return dpi;    }    /**     * Creates a map of driver properties whose <code>choices</code>     * field should be set when calling     * {@link #getPropertyInfo(String, Properties)}.     * <p/>     * The values in the map are the <code>String[]</code> objects     * that should be set to the <code>choices</code> field.     *     * @return The map of {@link DriverPropertyInfo} objects whose     *         <code>choices</code> should be set.     */    private static Map createChoicesMap() {        final HashMap choicesMap = new HashMap();        final String[] booleanChoices = new String[]{"true", "false"};        choicesMap.put(Messages.get(Driver.CACHEMETA), booleanChoices);        choicesMap.put(Messages.get(Driver.LASTUPDATECOUNT), booleanChoices);        choicesMap.put(Messages.get(Driver.NAMEDPIPE), booleanChoices);        choicesMap.put(Messages.get(Driver.TCPNODELAY), booleanChoices);        choicesMap.put(Messages.get(Driver.SENDSTRINGPARAMETERSASUNICODE), booleanChoices);        choicesMap.put(Messages.get(Driver.USECURSORS), booleanChoices);        choicesMap.put(Messages.get(Driver.USELOBS), booleanChoices);        choicesMap.put(Messages.get(Driver.XAEMULATION), booleanChoices);        final String[] prepareSqlChoices = new String[]{            String.valueOf(TdsCore.UNPREPARED),            String.valueOf(TdsCore.TEMPORARY_STORED_PROCEDURES),            String.valueOf(TdsCore.EXECUTE_SQL),            String.valueOf(TdsCore.PREPARE),        };        choicesMap.put(Messages.get(Driver.PREPARESQL), prepareSqlChoices);        final String[] serverTypeChoices = new String[]{            String.valueOf(SQLSERVER),            String.valueOf(SYBASE),        };        choicesMap.put(Messages.get(Driver.SERVERTYPE), serverTypeChoices);        final String[] tdsChoices = new String[]{            DefaultProperties.TDS_VERSION_42,            DefaultProperties.TDS_VERSION_50,            DefaultProperties.TDS_VERSION_70,            DefaultProperties.TDS_VERSION_80,        };        choicesMap.put(Messages.get(Driver.TDS), tdsChoices);        final String[] sslChoices = new String[]{            Ssl.SSL_OFF,            Ssl.SSL_REQUEST,            Ssl.SSL_REQUIRE,            Ssl.SSL_AUTHENTICATE        };        choicesMap.put(Messages.get(Driver.SSL), sslChoices);        return choicesMap;    }    /**     * Creates a map of driver properties that should be marked as     * required when calling {@link #getPropertyInfo(String, Properties)}.     * <p/>     * Note that only the key of the map is used to determine whether     * the <code>required</code> field should be set to <code>true</code>.     * If the key does not exist in the map, then the <code>required</code>     * field is set to <code>false</code>.     *     * @return The map of {@link DriverPropertyInfo} objects where     *         <code>required</code> should be set to <code>true</code>.     */    private static Map createRequiredTrueMap() {        final HashMap requiredTrueMap = new HashMap();        requiredTrueMap.put(Messages.get(Driver.SERVERNAME), null);        requiredTrueMap.put(Messages.get(Driver.SERVERTYPE), null);        return requiredTrueMap;    }    /**     * Parse the driver URL and extract the properties.     *     * @param url  the URL to parse     * @param info any existing properties already loaded in a     *             <code>Properties</code> object     * @return the URL properties as a <code>Properties</code> object     */    private static Properties parseURL(String url, Properties info) {        Properties props = new Properties();        // Take local copy of existing properties        for (Enumeration e = info.propertyNames(); e.hasMoreElements();) {            String key = (String) e.nextElement();            String value = info.getProperty(key);            if (value != null) {                props.setProperty(key.toUpperCase(), value);            }        }        StringBuffer token = new StringBuffer(16);        int pos = 0;        pos = nextToken(url, pos, token); // Skip jdbc        if (!"jdbc".equalsIgnoreCase(token.toString())) {            return null; // jdbc: missing        }        pos = nextToken(url, pos, token); // Skip jtds        if (!"jtds".equalsIgnoreCase(token.toString())) {            return null; // jtds: missing        }        pos = nextToken(url, pos, token); // Get server type        String type = token.toString().toLowerCase();        Integer serverType = DefaultProperties.getServerType(type);        if (serverType == null) {            return null; // Bad server type        }        props.setProperty(Messages.get(Driver.SERVERTYPE), String.valueOf(serverType));        pos = nextToken(url, pos, token); // Null token between : and //        if (token.length() > 0) {            return null; // There should not be one!        }        pos = nextToken(url, pos, token); // Get server name        String host = token.toString();        if (host.length() == 0) {            host = props.getProperty(Messages.get(Driver.SERVERNAME));            if (host == null || host.length() == 0) {                return null; // Server name missing            }        }        props.setProperty(Messages.get(Driver.SERVERNAME), host);        if (url.charAt(pos - 1) == ':' && pos < url.length()) {            pos = nextToken(url, pos, token); // Get port number            try {                int port = Integer.parseInt(token.toString());                props.setProperty(Messages.get(Driver.PORTNUMBER), Integer.toString(port));            } catch(NumberFormatException e) {                return null; // Bad port number            }        }        if (url.charAt(pos - 1) == '/' && pos < url.length()) {            pos = nextToken(url, pos, token); // Get database name            props.setProperty(Messages.get(DATABASENAME), token.toString());        }        //        // Process any additional properties in URL        //        while (url.charAt(pos - 1) == ';' && pos < url.length()) {            pos = nextToken(url, pos, token);            String tmp = token.toString();            int index = tmp.indexOf('=');            if (index > 0 && index < tmp.length() - 1) {                props.setProperty(tmp.substring(0, index).toUpperCase(), tmp.substring(index + 1));            } else {                props.setProperty(tmp.toUpperCase(), "");            }        }        return props;    }    /**     * Extract the next lexical token from the URL.     *     * @param url The URL being parsed     * @param pos The current position in the URL string.     * @param token The buffer containing the extracted token.     * @return The updated position as an <code>int</code>.     */    private static int nextToken(String url, int pos, StringBuffer token) {        token.setLength(0);        while (pos < url.length()) {            char ch = url.charAt(pos++);            if (ch == ':' || ch == ';') {                break;            }            if (ch == '/') {                if (pos < url.length() && url.charAt(pos) == '/') {                    pos++;                }                break;            }            token.append(ch);        }        return pos;    }    public static void main(String[] args) {        System.out.println("jTDS " + getVersion());    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -