Project

General

Profile

Revision 37b5850c

ID37b5850c6e84d9cb3913a6eb9c4bfe971a8fd056
Parent b8a15850
Child 2d427fc0

Added by Cherian Mathew about 7 years ago

added extra checks when parsing jdbc connection url

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/types/DatabaseTypeBase.java
113 113
	
114 114
	protected String getServerNameByConnectionString(String connectionString, String strUrl, String dbSeparator){
115 115
    	String result;
116
    	if (connectionString == null){
116
    	if (connectionString == null || !connectionString.startsWith(urlString)){
117 117
    		return null;
118 118
    	}
119 119
    	connectionString = connectionString.substring(strUrl.length());
......
137 137
    }
138 138
	
139 139
	protected int getPortByConnectionString(String connectionString, String strUrl, String dbSeparator){
140
		if (connectionString == null){
140
		if (connectionString == null || !connectionString.startsWith(urlString)){
141 141
    		return -1;
142 142
    	}
143 143
		int result;
......
166 166
	
167 167
	protected String getDatabasePartOfConnectionString(String connectionString, String dbSeparator){
168 168
    	String result;
169
    	if (connectionString == null){
169
    	if (connectionString == null || !connectionString.startsWith(urlString)){
170 170
    		return null;
171 171
    	}
172
    	
172 173
    	connectionString = connectionString.substring(urlString.length()); //delete prefix
173 174
    	int posDb = connectionString.indexOf(dbSeparator);
174 175
    	if (posDb != -1){
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/types/MySQLDatabaseType.java
55 55
    public String getDatabaseNameByConnectionString(String connectionString){
56 56
    	String result;
57 57
    	result = getDatabasePartOfConnectionString(connectionString, dbSeparator);
58
    	if(result == null) {
59
    		return null;
60
    	}
58 61
    	int posParams = result.indexOf("?");
59 62
    	if (posParams != -1){
60 63
    		result = result.substring(0, posParams);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)