Android Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsMobile ProgrammingAndroid Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 3rd, 2012, 01:23 PM
GruntledDroider GruntledDroider is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 3 GruntledDroider User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m
Reputation Power: 0
Mysql help

Hi, i have been banging my head into the wall with this so your help would be awesome! I am making an app that uses a MYSQL database so i am trying to connect to the database and it will not work. This might be more of a Java question, but it is for a Droid app so i am putting it here.

function in Worker class:

Code:
Connection connection = null;

public String connectToDB() {
	String dbURL = "jdbc:mysql://localhost:3306/database";
	String username = "root";
	String password = "pass";

	Class.forName("com.mysl.jdbc.Driver").newInstance();
        connection = DriverManager.getConnection(dbURL, username, password);
				
        if(connection != null){
	        conResult = "connected";
	}else{
		conResult = "not connected";
	}
	return conResult;
}


Class that uses above code:

Code:
Worker dbWorker = new Worker();

String test = dbWorker.connectToDB();
Toast t = Toast.makeText(this, test, Toast.LENGTH_LONG);
t.show();


i am only showing the code that i think is relevant. i must be missing something i keep getting the toast that says not connected

i did not add the try/catches to this post to keep it clean.
i am using eclipse

things i have tried:
- i have added the mysql connector to the library and set the path
- the file is copy to the /ext file and the /bin in my java file
- the firewall on port 3306 has been disabled
- my password is correct


Oh i also started using an older connector mysql-connector-java-3.0.17-ga because someone said that would make it work.

Reply With Quote
  #2  
Old February 6th, 2012, 02:54 PM
GruntledDroider GruntledDroider is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 3 GruntledDroider User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m
Reputation Power: 0
For those of you stuck in my position i figured it out....

i don't think mysql really works with droid so don't bother even trying the above method..... that is designed more for java.... you have to upload some php to your server to interact with your database for you and use JSON to pass information in between.

also, FYI droid cannot read localhost because it will look at the device not your PC so make sure you use your IP address in place of localhost

Reply With Quote
Reply

Viewing: Dev Shed ForumsMobile ProgrammingAndroid Development > Mysql help

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap